Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

chore(notifications): notifications filter indexes (#1675)

teo20e69bac353b
diff --git a/rust/cloud-storage/macro_db_client/migrations/20260225154836_notification_filter_indexes.sql b/rust/cloud-storage/macro_db_client/migrations/20260225154836_notification_filter_indexes.sql
new file mode 100644
index 0000000000..2e8b0dc180
--- /dev/null
+++ b/rust/cloud-storage/macro_db_client/migrations/20260225154836_notification_filter_indexes.sql
@@ -0,0 +1,11 @@
+-- Composite index on notification for the EXISTS subqueries in soup/frecency/comms
+-- dynamic filters that filter on both event_item_type and event_item_id.
+CREATE INDEX IF NOT EXISTS idx_notification_event_type_id
+ ON notification (event_item_type, event_item_id);
+
+-- Partial covering index for the EXISTS subquery used in soup/frecency/comms
+-- dynamic filters. Covers done and seen_at so Postgres can evaluate the filter
+-- predicate directly from the index without heap access.
+CREATE INDEX IF NOT EXISTS idx_user_notification_active_filter
+ ON user_notification (user_id, notification_id, done, seen_at)
+ WHERE deleted_at IS NULL;