fix(sql): restore partial WHERE is_active predicate on listings indexes (#1398) #1693

Merged
lekss361 merged 1 commit from fix/listings-partial-indexes-1398 into main 2026-06-17 18:05:31 +00:00
Owner

Проблема (#1398)

097_index_hygiene.sql де-партиализовал listings-индексы на ложной посылке; миграция 104 признала посылку устаревшей → partial-гигиена не восстановлена (~51% inactive строк → индексы вдвое больше нужного).

Решение

Миграция 120_restore_partial_active_indexes.sql — 3 индекса с WHERE is_active = true:

  • listings_active_filter_idx (rooms, price_rub, area_m2, scraped_at DESC) — бэкает _COMMON_WHERE estimator
  • listings_house_price_idx (house_id_fk, price_rub)
  • listings_rooms_area_idx (rooms, area_m2)

Исключены: listings_geom_active_idx (104 убрал как dup GIST), listings_scraped_desc_idx (issue сам опускает). CONCURRENTLY не используется (раннер оборачивает в BEGIN/COMMIT, как миграция 117).

Verify

SQL parses. EXPLAIN из source-path (_COMMON_WHERE: rooms+area_m2+price_rub+is_active) — postgres-tradein MCP в сессии воркера был недоступен, предикат сверен по коду estimator.

Closes #1398

## Проблема (#1398) `097_index_hygiene.sql` де-партиализовал listings-индексы на ложной посылке; миграция 104 признала посылку устаревшей → partial-гигиена не восстановлена (~51% inactive строк → индексы вдвое больше нужного). ## Решение Миграция `120_restore_partial_active_indexes.sql` — 3 индекса с `WHERE is_active = true`: - `listings_active_filter_idx (rooms, price_rub, area_m2, scraped_at DESC)` — бэкает `_COMMON_WHERE` estimator - `listings_house_price_idx (house_id_fk, price_rub)` - `listings_rooms_area_idx (rooms, area_m2)` Исключены: `listings_geom_active_idx` (104 убрал как dup GIST), `listings_scraped_desc_idx` (issue сам опускает). CONCURRENTLY не используется (раннер оборачивает в BEGIN/COMMIT, как миграция 117). ## Verify SQL parses. EXPLAIN из source-path (`_COMMON_WHERE`: rooms+area_m2+price_rub+is_active) — `postgres-tradein` MCP в сессии воркера был недоступен, предикат сверен по коду estimator. Closes #1398
lekss361 added 1 commit 2026-06-17 17:56:48 +00:00
fix(sql): restore partial predicate on 5 listings indexes (#1398)
All checks were successful
CI / changes (push) Successful in 7s
CI / changes (pull_request) Successful in 8s
CI / backend-tests (push) Has been skipped
CI / frontend-tests (push) Has been skipped
CI / openapi-codegen-check (push) Has been skipped
CI / frontend-tests (pull_request) Has been skipped
CI / backend-tests (pull_request) Has been skipped
CI / openapi-codegen-check (pull_request) Has been skipped
403020ad56
097_index_hygiene.sql de-partialized 5 listings indexes on the false premise
that is_active=100% true. 104_index_hygiene_geom_dedup.sql acknowledged the
premise is stale (49% active on prod, 2026-06-13) but only cleaned up the
redundant geom duplicate, leaving 3 composite indexes full.

Restore WHERE is_active=true on the composite hot-path indexes:
- listings_active_filter_idx (rooms, price_rub, area_m2, scraped_at DESC)
- listings_house_price_idx   (house_id_fk, price_rub)
- listings_rooms_area_idx    (rooms, area_m2)

Excluded: listings_geom_active_idx (dropped by 104, listings_geom_idx covers it),
listings_scraped_desc_idx (not in issue #1398 suggested fix scope).

CONCURRENTLY not used — migration runner wraps in BEGIN/COMMIT (see 117 note).
lekss361 merged commit 1fffb7a0a7 into main 2026-06-17 18:05:31 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lekss361/gendesign#1693
No description provided.