C1: Materialized view part_vehicle_preview (creación en progreso) - Migración v3.3_materialized_view.sql - catalog_service.py y dashboard/server.py ahora usan la MV - Script refresh_part_vehicle_preview.py + warm_vehicle_cache.py actualizado C2: Fix cache warming script (autónomo) - Auto-re-ejecuta con sudo -u postgres si peer auth falla - Args CLI: --dsn, --batch-size, --ttl, --dry-run C3: CSS dinámico residual extraído - sidebar.js → sidebar.css (nuevo) - pos-utils.js → common.css (nuevo) - Links agregados a 14 templates POS C4: Script de load testing básico - scripts/load_test.py: métricas p50/p95/p99, throughput, errores C5: Documentación actualizada - FASES_IMPLEMENTADAS.md: test count real, FASE 7 completa - performance_audit_2026.md: anexo post-FASE 7, métricas actualizadas A1: Serialización orjson - pos/json_provider.py: DefaultJSONProvider con orjson.dumps/loads - Aplicado a POS app y Dashboard server - Fix indentation error en pos_bp.py Tests: 73/73 pasando
32 lines
1.2 KiB
SQL
32 lines
1.2 KiB
SQL
-- Migration v3.3: Materialized view part_vehicle_preview
|
|
-- Purpose: Pre-compute the "most recent vehicle" per part to eliminate
|
|
-- DISTINCT ON + 4 JOINs over vehicle_parts (254 GB, 2B+ rows) at query time.
|
|
--
|
|
-- Notes:
|
|
-- - CREATE MATERIALIZED VIEW without CONCURRENTLY (first creation).
|
|
-- - REFRESH MATERIALIZED VIEW CONCURRENTLY is possible after the unique index exists.
|
|
-- - Run with statement_timeout = 0; this may take hours on first creation.
|
|
|
|
SET statement_timeout = 0;
|
|
|
|
DROP MATERIALIZED VIEW IF EXISTS part_vehicle_preview;
|
|
|
|
CREATE MATERIALIZED VIEW part_vehicle_preview AS
|
|
SELECT DISTINCT ON (vp.part_id)
|
|
vp.part_id,
|
|
b.name_brand,
|
|
m.name_model,
|
|
y.year_car
|
|
FROM vehicle_parts vp
|
|
JOIN model_year_engine mye ON mye.id_mye = vp.model_year_engine_id
|
|
JOIN models m ON m.id_model = mye.model_id
|
|
JOIN brands b ON b.id_brand = m.brand_id
|
|
JOIN years y ON y.id_year = mye.year_id
|
|
ORDER BY vp.part_id, y.year_car DESC;
|
|
|
|
CREATE UNIQUE INDEX idx_pvp_part ON part_vehicle_preview(part_id);
|
|
CREATE INDEX idx_pvp_brand ON part_vehicle_preview(name_brand);
|
|
|
|
-- Grant select to application roles if needed
|
|
-- GRANT SELECT ON part_vehicle_preview TO nexus_app;
|