gendesign/backend/tests/services/generative
Light1YT 74f1ffb500
All checks were successful
CI / changes (pull_request) Successful in 6s
CI / frontend-tests (pull_request) Has been skipped
CI / openapi-codegen-check (pull_request) Successful in 1m49s
CI / backend-tests (pull_request) Successful in 13m58s
perf(objective): request-path consumers dedup inline, not via whole-table view (#1964)
deep-review #1964: v_objective_lots_latest has NO premise/district filter inside,
so a consumer's outer WHERE cannot push below DISTINCT ON → the view materializes
the WHOLE table (Parallel Seq Scan + external Sort 1.76M rows, ~55MB spill) on
every query. For REQUEST-PATH consumers inside analyze_parcel this is a ~19x latency
regression vs the pre-#1964 raw-table plan.

DISPROVEN remedy (NOT applied): a full index on the physflat-key does NOT help —
DISTINCT ON selects ol.* (51 cols, width≈945) so index-only-unique is impossible;
the planner ignores the index (seq-scan+sort still cheaper) and even forced it is
~3.9 s. A 142MB index for zero request-path benefit + slower bulk-INSERT during
objective-scrape is wrong. Honors original #1964 decision "no new index".

Prod EXPLAIN (Академический / 3km radius, 2026-06-28):
  consumer            via view      inline (this commit)
  concepts median     5854 ms       1640 ms   (bitmap district + sort)
  parcels district    5854 ms       1640 ms
  parcels geo-median  6443 ms        122 ms   (NestedLoop geo->complex bitmap)
  parcels obj_pricing 5721 ms        441 ms   (project bitmap per nearby ЖК)

FIX: keep v_objective_lots_latest ONLY for batch/background/cached consumers
(supply_layers L1, competitors._SOLD_COUNT_SQL, special_indices [/forecast bg task
30-180s], admin, landing). Revert the 4 request-path consumers inside analyze_parcel
to inline DISTINCT ON (physflat-key, latest snapshot) with the filter pushed INTO the
CTE so the district/spatial/project index applies:
- concepts._OBJECTIVE_MEDIAN_SQL
- parcels.py district price block
- parcels.py geo-radius median (complex_id-scoped)
- parcels.py obj_pricing CTE (project_name-scoped; aggregates over deduped set)

Migration 175 header CORRECTED: accurately states the partial mig-173 index does NOT
serve the view (qual can't push below DISTINCT ON), the full index is disproven/not
added, and which consumers use the view vs inline. No DDL change (still view-only).

Tests: +guards (concepts/obj_pricing dedup inline, not view; obj_pricing physflat
DISTINCT ON; perf-pushdown scope preserved). 965 passed.
2026-06-28 05:00:47 +05:00
..
test_api_concepts.py feat(concept): фронт-пикер типовых домов (#1965 Stage 3b) 2026-06-28 02:49:44 +05:00
test_catalog.py feat(concept): house-type catalog + program-driven placement (#1965 Stage 3a) 2026-06-28 01:29:04 +05:00
test_exporters.py feat(finmodel): monthly DCF — real NPV/IRR/PBP, replace IRR-proxy (epic #1881 PR-3) 2026-06-23 21:52:04 +05:00
test_financial_dcf.py feat(financial/dcf): dormant separate-index inflation capability (default OFF) 2026-06-25 12:12:02 +00:00
test_geometry.py feat(generative): exporters (dxf/pdf) + generative test suite (#54 #55 #56) 2026-06-13 21:33:20 +05:00
test_market_price_lookup.py perf(objective): request-path consumers dedup inline, not via whole-table view (#1964) 2026-06-28 05:00:47 +05:00
test_placement.py feat(generative): exporters (dxf/pdf) + generative test suite (#54 #55 #56) 2026-06-13 21:33:20 +05:00
test_program_placement.py test(concept): turn greedy backward-compat into a real golden pin (#1965 Stage 3a) 2026-06-28 02:23:55 +05:00
test_teap_financial.py feat(generative): LIVE financial recompute from massing program (#1965 Stage 2a) 2026-06-28 00:27:25 +05:00