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);