feat(obj-2): mapping backfill via pre-materialized temp tables (migration 117) #327

Merged
lekss361 merged 1 commit from feat/117-obj2-mapping-backfill-fast into main 2026-05-17 20:34:42 +00:00

1 commit

Author SHA1 Message Date
lekss361
5f50a7ec96 feat(obj-2): mapping backfill via pre-materialized temp tables (117)
Continues from migration 116 (trimmed to GIST index only after timeout).

Algorithm:
1. Materialize unmapped DOM.РФ ЕКБ objects → _u_domrf (~1056 rows)
2. Materialize unmapped Objective projects → _u_obj (~178 rows)
3. CROSS JOIN LATERAL with top-3 per obj_id, leveraging GIST trgm index from 116
4. Composite score = name_sim*0.6 + dev_match*0.25 + district_match*0.15
5. INSERT auto-accepted (composite >= 0.75) with ON CONFLICT DO NOTHING

Why pre-materialize: original CTE recomputed unmapped lists for every row,
costing 89M and timing out. Temp tables compute once + GIST index = <30s.

Expected: +50-80 mappings, total ~200. Coverage Site Finder competitors
улучшится с 15% до ~40-60% (особенно для районов с Объективными devs).
2026-05-17 23:28:52 +03:00