From 33f06d31046acccf53b595b87b7bc5aedce104e7 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Thu, 19 Oct 2023 13:00:07 -0700 Subject: [PATCH] Index notifications to allow faster lookup by kind, entity id --- .../collab/migrations.sqlite/20221109000000_test_schema.sql | 5 ++++- .../migrations/20231004130100_create_notifications.sql | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/collab/migrations.sqlite/20221109000000_test_schema.sql b/crates/collab/migrations.sqlite/20221109000000_test_schema.sql index a8dd7eb091..7fa808b498 100644 --- a/crates/collab/migrations.sqlite/20221109000000_test_schema.sql +++ b/crates/collab/migrations.sqlite/20221109000000_test_schema.sql @@ -341,4 +341,7 @@ CREATE TABLE "notifications" ( "response" BOOLEAN ); -CREATE INDEX "index_notifications_on_recipient_id_is_read" ON "notifications" ("recipient_id", "is_read"); +CREATE INDEX + "index_notifications_on_recipient_id_is_read_kind_entity_id" + ON "notifications" + ("recipient_id", "is_read", "kind", "entity_id"); diff --git a/crates/collab/migrations/20231004130100_create_notifications.sql b/crates/collab/migrations/20231004130100_create_notifications.sql index cdc6674ff1..93c282c631 100644 --- a/crates/collab/migrations/20231004130100_create_notifications.sql +++ b/crates/collab/migrations/20231004130100_create_notifications.sql @@ -16,4 +16,7 @@ CREATE TABLE notifications ( "response" BOOLEAN ); -CREATE INDEX "index_notifications_on_recipient_id" ON "notifications" ("recipient_id"); +CREATE INDEX + "index_notifications_on_recipient_id_is_read_kind_entity_id" + ON "notifications" + ("recipient_id", "is_read", "kind", "entity_id");