From c3d6fc00619ab6c1118e877ccf0aef91a1c91226 Mon Sep 17 00:00:00 2001 From: Lucas Meier Date: Tue, 10 Sep 2024 16:25:20 -0700 Subject: [PATCH] cometindex: add index for attributes referencing events This is needed to efficiently get the attributes for an event. Without this performance explodes if pindexer is far behind. --- crates/util/cometindex/vendor/schema.sql | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/util/cometindex/vendor/schema.sql b/crates/util/cometindex/vendor/schema.sql index ce5a241bad..fd78e677e0 100644 --- a/crates/util/cometindex/vendor/schema.sql +++ b/crates/util/cometindex/vendor/schema.sql @@ -65,6 +65,9 @@ CREATE TABLE attributes ( UNIQUE (event_id, key) ); +-- To make it efficient to fetch the attributes of a given event. +CREATE INDEX ON attributes(event_id); + -- A joined view of events and their attributes. Events that do not have any -- attributes are represented as a single row with empty key and value fields. CREATE VIEW event_attributes AS