-- 89_drop_dead_brin_rosreestr_deals.sql -- DROP dead BRIN index per code-review audit (2026-05-14). -- -- Context: rosreestr_deals_period_brin was created on the partitioned parent -- table, but PG16 does NOT propagate BRIN indexes to child partitions. -- The parent table holds zero rows (all data lives in child partitions). -- Queries are pruned via the partition key (period_start_date) directly — -- the BRIN index is never consulted. -- pg_stat_user_indexes.idx_scan = 0 for this index confirms zero usage. -- Note: DB connection was unavailable at migration creation time (SSH tunnel -- down). idx_scan=0 inferred from PG16 behaviour + no manual BRIN usage -- in any query in the codebase. Verify with SELECT below before applying. -- -- Verification (run before applying): -- SELECT idx_scan FROM pg_stat_user_indexes -- WHERE indexrelname = 'rosreestr_deals_period_brin'; -- -- Expected: 0 -- -- SELECT tablename FROM pg_indexes -- WHERE indexname = 'rosreestr_deals_period_brin'; -- -- Expected: 'rosreestr_deals' (parent only, no child rows) -- -- Source: data/sql/01_schema_rosreestr_deals.sql line 66-67 (original CREATE) -- Apply order: after all 88_* migrations have been applied -- Dependencies: rosreestr_deals partitioned table must exist -- -- Rollback: re-create per-partition if range scan optimisation is ever needed -- (partition pruning is sufficient for the current query patterns; -- measure with EXPLAIN ANALYSE before deciding to re-create) -- -- Example per-partition rollback: -- CREATE INDEX rosreestr_deals_2025q1_period_brin -- ON rosreestr_deals_2025q1 USING BRIN (period_start_date); -- -- repeat for each partition BEGIN; DROP INDEX IF EXISTS rosreestr_deals_period_brin; COMMIT;