perf(db): physflat-covering индекс v2 с price_per_m2_rub в INCLUDE (#2177 follow-up) #2243

Merged
bot-backend merged 1 commit from feat/physflat-idx-include into main 2026-07-03 00:49:08 +00:00

1 commit

Author SHA1 Message Date
a83dd582a6 data/sql/183: physflat covering index v2 with price_per_m2_rub (#2240)
All checks were successful
CI / changes (pull_request) Successful in 9s
CI Trade-In / changes (pull_request) Successful in 10s
CI Trade-In / backend-tests (pull_request) Has been skipped
CI Trade-In / frontend-checks (pull_request) Has been skipped
CI / frontend-tests (pull_request) Has been skipped
CI / openapi-codegen-check (pull_request) Successful in 2m7s
CI / backend-tests (pull_request) Successful in 14m20s
Follow-up review #2240: best_layouts._SUPPLY_ONLY_LOTS_SQL projects
price_per_m2_rub after DISTINCT ON (physflat), but the 176-й covering
index does not carry it in INCLUDE, so Index-Only Scan is impossible and
heavy projects fall back to heap scan + external-merge Sort (~7 MB temp,
~500 ms).

Rebuild the covering index as v2 with price_per_m2_rub added to INCLUDE.
Same key + partial-WHERE as 176-й, so all prior consumers are unchanged;
supply-only now gets Index Only Scan (~54 ms, prod EXPLAIN on the two
heaviest projects).

CREATE new v2 name -> DROP old (mirrors 176-й ordering; never a window
without a covering index under DISTINCT ON). Plain CREATE INDEX in
BEGIN/COMMIT, NOT CONCURRENTLY: deploy.yml pipes each .sql whole through
psql and the file self-wraps in BEGIN/COMMIT, where CONCURRENTLY is
forbidden (same policy as 168-й/176-й). Deploy outside the weekly
objective-scrape window (~252 MB build under brief SHARE-lock on
objective_lots, ~1.9M rows). ANALYZE at end of tx.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-03 05:32:56 +05:00