Skip to content

Commit 7a5fcee

Browse files
authored
fix(knowledge): index the connector tombstone check so a sync stops scanning the whole document table (#8122)
* fix(knowledge): index the connector tombstone check so a sync stops scanning the whole document table * chore(db): format the generated migration metadata
1 parent cb7de98 commit 7a5fcee

4 files changed

Lines changed: 28469 additions & 0 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
-- The connector sync checks whether a connector still carries a recently deleted or never-hydrated
2+
-- document. With no index matching that predicate the planner scans the whole table for the first
3+
-- match, and a connector with none reads every row on every sync.
4+
COMMIT;--> statement-breakpoint
5+
SET lock_timeout = 0;--> statement-breakpoint
6+
-- migration-safe: replay replaces only this new index to recover an interrupted concurrent build; existing indexes remain available.
7+
DROP INDEX CONCURRENTLY IF EXISTS "doc_connector_tombstone_idx";--> statement-breakpoint
8+
CREATE INDEX CONCURRENTLY IF NOT EXISTS "doc_connector_tombstone_idx" ON "document" USING btree ("connector_id") WHERE "archived_at" IS NULL AND ("deleted_at" IS NOT NULL OR "content_hash" IS NULL);--> statement-breakpoint
9+
SET lock_timeout = '5s';

0 commit comments

Comments
 (0)