You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(file-search): seek the backfill cursor instead of rescanning each page
The hourly backfill walks every live workspace file by `(workspace_id, id)`,
but no index supplied that order under its predicate, so each page sorted the
whole remaining set and the dispatcher's 10s statement timeout aborted the
transaction before any page committed.
Adds the matching partial index and compares the cursor row-wise. The previous
`workspace_id > :ws OR (workspace_id = :ws AND id > :id)` spelling is only ever
an index filter, never an index condition, so even with the index each page
restarted at the low end and rescanned every page before it.
On a prod-shaped fixture (5.5M files, 94k live) a full 95-page walk goes from
786ms to 42ms; the index alone accounts for 786ms -> 267ms and the row-wise
cursor for the rest.
-- migration-safe: replay replaces only this new index to recover an interrupted concurrent build; existing indexes remain available.
4
+
DROPINDEX CONCURRENTLY IF EXISTS "workspace_files_workspace_active_keyset_idx";--> statement-breakpoint
5
+
CREATEINDEXCONCURRENTLY IF NOT EXISTS "workspace_files_workspace_active_keyset_idx"ON"workspace_files" USING btree ("workspace_id","id") WHERE"workspace_files"."deleted_at" IS NULLAND"workspace_files"."context"='workspace'AND"workspace_files"."workspace_id"IS NOT NULL;--> statement-breakpoint
0 commit comments