From c3030dfa5bc7c4f9efee9f39066362b405b373f4 Mon Sep 17 00:00:00 2001 From: Tim Diekmann <21277928+TimDiekmann@users.noreply.github.com> Date: Mon, 2 Dec 2024 22:32:27 +0100 Subject: [PATCH] H-3723: Add link table indices (#5771) --- .../graph/migrations/graph-migrations/v009__entities/up.sql | 4 ++++ .../postgres_migrations/V36__link_table_indices.sql | 4 ++++ 2 files changed, 8 insertions(+) create mode 100644 libs/@local/graph/postgres-store/postgres_migrations/V36__link_table_indices.sql diff --git a/libs/@local/graph/migrations/graph-migrations/v009__entities/up.sql b/libs/@local/graph/migrations/graph-migrations/v009__entities/up.sql index 78d09db8fd4..00a24e2632e 100644 --- a/libs/@local/graph/migrations/graph-migrations/v009__entities/up.sql +++ b/libs/@local/graph/migrations/graph-migrations/v009__entities/up.sql @@ -76,6 +76,8 @@ CREATE TABLE entity_has_left_entity ( FOREIGN KEY (web_id, entity_uuid) REFERENCES entity_ids, FOREIGN KEY (left_web_id, left_entity_uuid) REFERENCES entity_ids ); +CREATE INDEX entity_has_left_entity_source_idx + ON entity_has_left_entity(web_id, entity_uuid); CREATE TABLE entity_has_right_entity ( web_id UUID NOT NULL, @@ -87,6 +89,8 @@ CREATE TABLE entity_has_right_entity ( FOREIGN KEY (web_id, entity_uuid) REFERENCES entity_ids, FOREIGN KEY (right_web_id, right_entity_uuid) REFERENCES entity_ids ); +CREATE INDEX entity_has_right_entity_source_idx + ON entity_has_right_entity(web_id, entity_uuid); CREATE TABLE entity_embeddings ( web_id UUID NOT NULL, diff --git a/libs/@local/graph/postgres-store/postgres_migrations/V36__link_table_indices.sql b/libs/@local/graph/postgres-store/postgres_migrations/V36__link_table_indices.sql new file mode 100644 index 00000000000..736da258f7c --- /dev/null +++ b/libs/@local/graph/postgres-store/postgres_migrations/V36__link_table_indices.sql @@ -0,0 +1,4 @@ +CREATE INDEX entity_has_left_entity_source_idx + ON entity_has_left_entity(web_id, entity_uuid); +CREATE INDEX entity_has_right_entity_source_idx + ON entity_has_right_entity(web_id, entity_uuid);