Skip to content

Commit 6151605

Browse files
authored
fix(db): index the keyword projection by document, and drop the unread binary ANN indexes (#8105)
1 parent 2cecb21 commit 6151605

6 files changed

Lines changed: 56901 additions & 31 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
-- Drops the five binary-quantized ANN indexes on "embedding_search". Ranking walks the
2+
-- half-precision graphs; no reader has ordered by a hamming distance on this projection since
3+
-- half-precision search shipped, so each index was maintained on every chunk write for nothing,
4+
-- and the populated one doubled the cost of filling the projection's source and ACL columns.
5+
-- The binary columns stay for now: the projection sync trigger still writes them.
6+
COMMIT;--> statement-breakpoint
7+
SET lock_timeout = 0;--> statement-breakpoint
8+
-- migration-safe: DROP INDEX CONCURRENTLY IF EXISTS is idempotent on replay and takes no blocking lock.
9+
DROP INDEX CONCURRENTLY IF EXISTS "embedding_search_binary_hnsw_idx";--> statement-breakpoint
10+
-- migration-safe: DROP INDEX CONCURRENTLY IF EXISTS is idempotent on replay and takes no blocking lock.
11+
DROP INDEX CONCURRENTLY IF EXISTS "embedding_search_384_binary_hnsw_idx";--> statement-breakpoint
12+
-- migration-safe: DROP INDEX CONCURRENTLY IF EXISTS is idempotent on replay and takes no blocking lock.
13+
DROP INDEX CONCURRENTLY IF EXISTS "embedding_search_768_binary_hnsw_idx";--> statement-breakpoint
14+
-- migration-safe: DROP INDEX CONCURRENTLY IF EXISTS is idempotent on replay and takes no blocking lock.
15+
DROP INDEX CONCURRENTLY IF EXISTS "embedding_search_1024_binary_hnsw_idx";--> statement-breakpoint
16+
-- migration-safe: DROP INDEX CONCURRENTLY IF EXISTS is idempotent on replay and takes no blocking lock.
17+
DROP INDEX CONCURRENTLY IF EXISTS "embedding_search_3072_binary_hnsw_idx";--> statement-breakpoint
18+
SET lock_timeout = '5s';
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
-- The document ACL trigger fans a document's source and ACL out to the keyword projection by
2+
-- document id; with no index on that column every ACL change scanned the whole projection.
3+
COMMIT;--> statement-breakpoint
4+
SET lock_timeout = 0;--> statement-breakpoint
5+
-- migration-safe: replay replaces only this new index to recover an interrupted concurrent build; existing indexes remain available.
6+
DROP INDEX CONCURRENTLY IF EXISTS "embedding_keyword_tin_document_idx";--> statement-breakpoint
7+
CREATE INDEX CONCURRENTLY IF NOT EXISTS "embedding_keyword_tin_document_idx" ON "embedding_keyword_tin" USING btree ("document_id");--> statement-breakpoint
8+
SET lock_timeout = '5s';

0 commit comments

Comments
 (0)