Commit graph

2 commits

Author SHA1 Message Date
lekss361
a10c47230b fix(tradein-sql): remove duplicate CREATE INDEX from 050 (regression from PR #500)
PR #500 added 035_drop_duplicate_indexes.sql to drop listing_sources_listing_idx2
and houses_geom_idx2, but 050_search_optimization.sql re-CREATED them on every
deploy (sort order: 035 DROP → 050 CREATE). End state: dupes restored.

Verified on prod 2026-05-24 ~12:08 via docker exec tradein-postgres psql.

Fix: remove the two CREATE INDEX statements from 050 at the source. After this
PR, deploy order becomes: 035 DROPs (succeeds on existing dupes) → 050 doesn't
recreate → final state matches PR #500's intent.

Migration 035 retained as the durable DROP guard.
2026-05-24 15:12:26 +03:00
e46b7d778e feat(tradein): search matview + indexes (Phase 3.1) (#469)
All checks were successful
Deploy Trade-In / changes (push) Successful in 5s
Deploy Trade-In / build-frontend (push) Has been skipped
Deploy Trade-In / deploy (push) Successful in 22s
Deploy Trade-In / build-backend (push) Successful in 43s
Multi-Source Integration Phase 3.1. Foundation for /api/v1/search p95 < 100ms on 100K+ listings.

SQL 050_search_optimization.sql:
- CREATE EXTENSION IF NOT EXISTS pg_trgm
- ALTER listings ADD COLUMN tsv tsvector GENERATED ALWAYS AS (...) STORED
- 10 indexes (geom GIST, composite, gin_trgm, GIN tsv, partial kadastr, ...)
- CREATE MATERIALIZED VIEW listings_search_mv (per-listing aggregated across sources)
- 5 matview indexes (UNIQUE on listing_id for REFRESH CONCURRENTLY)

Celery task tradein.refresh_search_matview:
- REFRESH MATERIALIZED VIEW CONCURRENTLY listings_search_mv (psycopg v3)
- Logged duration via logger.info
- Graceful try/except ImportError fallback (no celery_app.py in tradein-mvp yet)
- Beat schedule snippet in docstring for future wiring

Fixups (deep-code-reviewer 2026-05-23):
- h.ratings_count → h.reviews_count (alias house_ratings_count preserved)
- Strip +psycopg dialect prefix from DSN for libpq compat

Refs Master Plan sec 5.1 + 6.5 + 10.1.
2026-05-23 14:01:18 +00:00