perf(tradein): index hygiene — drop dup/redundant + de-partial is_active (#730) #897
No reviewers
Labels
No labels
admin
analytics
auth
automation
bug
business
chore
ci
compliance
data
data-moat
docs
duplicate
dx
enhancement
Fable 5 ревью
feedback/max
generative
GG-форсайт
needs-discussion
needs-human
observability
pause-bots
performance
priority/p0
priority/p1
priority/p2
priority/p3
scope/backend
scope/db
scope/devops
scope/frontend
scope/qa
scrapers
security
site-finder
stage/1
stage/2
status/blocked
status/done
status/needs-analysis
status/needs-fix
status/qa
status/ready
status/review
status/wip
tech-debt
tradein
ux
week ревью 1
wontfix
вторичка
ИРД
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: lekss361/gendesign#897
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "feat/730-index-hygiene"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Deterministic subset of
TradeinDb_Audit_May30(Part 1 + Part 3.4). Migration 097index_hygiene.sql(BEGIN/COMMIT,IF EXISTS/IF NOT EXISTS, idempotent). Every target was traced to its realCREATE INDEXin migration history (file:line in the SQL header).Drops (5) — 4 exact duplicates (identical twin survives → no plan change) + 1 redundant:
houses_kadastr_idx2→ twinhouses_cadastral_number_idxhouses_addr_fp_idx→ twinhouses_fingerprint_idx2listings_scraped_idx→ twinlistings_scraped_desc_idxlisting_sources_price_divergence_idx→ twin..._idx2houses_source_ext_idx→ redundant, covered by theUNIQUE(source, ext_house_id)backing index (the plain btree is dropped; the unique index stays).De-partial (5) —
listingsindexes withWHERE is_active=true; since is_active is 100% true the predicate saves nothing and a full index strictly covers the partial (no regression):listings_geom_active_idx,listings_active_filter_idx,listings_house_price_idx,listings_scraped_desc_idx,listings_rooms_area_idx→ eachDROP+CREATEwithout the predicate, same columns/order.Out of scope (deferred)
The 87 unused indexes sweep is NOT in this PR — it requires a fresh live
pg_stat_user_indexessnapshot (idx_scan=0) which is not available from the headless env. Follow-up needs a DB session.Test plan
CREATEhas exactly one precedingDROP; every target traced to a real CREATE INDEX line.pg_stat_user_indexes WHERE idx_scan=0snapshot; after apply confirm dupes gone + size saved + EXPLAIN on hot estimator //sales-vs-listingsqueries shows no plan regression.⚠️ Migration auto-applies to prod on deploy. The DDL itself is low-risk (dup drops can't change results; full indexes cover the de-partialed ones), but the GIST
geomrecreate has a brief rebuild window. Given demo is 2026-06-01, recommend reviewer hold merge until post-demo + run the live EXPLAIN check, then apply in a low-traffic window.Refs #730