Skip to content

Commit a5815cb

Browse files
committed
improvement(db): drop unusable date slot and redundant prefix indexes
1 parent ec0f474 commit a5815cb

4 files changed

Lines changed: 29339 additions & 14 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
-- Generated by drizzle-kit, then converted to CONCURRENTLY per scripts/migrate.ts (plain
2+
-- DROP INDEX takes ACCESS EXCLUSIVE for the whole op, write-locking the table).
3+
--
4+
-- DROP date tag-slot indexes on embedding and document. Tag filters compare `col::date`, which a
5+
-- plain timestamp btree can never match, so these are maintained on every chunk insert and
6+
-- document update without ever serving a query. The number and boolean slot indexes are kept:
7+
-- selective filters on those slots rely on them.
8+
--
9+
-- DROP redundant indexes, each a left-prefix of an existing non-partial superset, so the
10+
-- superset still serves equality lookups and foreign-key cascades on the leading column:
11+
-- emb_kb_id_idx ⊂ emb_kb_enabled_idx, emb_kb_model_idx
12+
-- emb_doc_id_idx ⊂ emb_doc_chunk_idx, emb_doc_enabled_idx
13+
-- usage_log_workspace_id_idx ⊂ usage_log_workspace_created_at_idx
14+
-- copilot_runs_execution_id_idx ⊂ copilot_runs_execution_started_at_idx
15+
--
16+
-- The embedded COMMIT drops out of drizzle's batch transaction; everything below runs in
17+
-- autocommit (CONCURRENTLY cannot run in a transaction) and is idempotent for safe replay.
18+
COMMIT;--> statement-breakpoint
19+
SET lock_timeout = 0;--> statement-breakpoint
20+
DROP INDEX CONCURRENTLY IF EXISTS "emb_date1_idx";--> statement-breakpoint
21+
DROP INDEX CONCURRENTLY IF EXISTS "emb_date2_idx";--> statement-breakpoint
22+
DROP INDEX CONCURRENTLY IF EXISTS "doc_date1_idx";--> statement-breakpoint
23+
DROP INDEX CONCURRENTLY IF EXISTS "doc_date2_idx";--> statement-breakpoint
24+
DROP INDEX CONCURRENTLY IF EXISTS "emb_kb_id_idx";--> statement-breakpoint
25+
DROP INDEX CONCURRENTLY IF EXISTS "emb_doc_id_idx";--> statement-breakpoint
26+
DROP INDEX CONCURRENTLY IF EXISTS "usage_log_workspace_id_idx";--> statement-breakpoint
27+
DROP INDEX CONCURRENTLY IF EXISTS "copilot_runs_execution_id_idx";--> statement-breakpoint
28+
SET lock_timeout = '5s';

0 commit comments

Comments
 (0)