Files
ems/db/migration/V079__pv_delta_profile_cache.sql
Dusan Vojacek d984716f69
Some checks failed
CI and deploy / migration-check (push) Failing after 12s
CI and deploy / deploy (push) Has been skipped
speedup zalozka planning
2026-05-21 10:37:32 +02:00

24 lines
1.0 KiB
SQL

-- Cache výsledku fn_pv_forecast_delta_profile per site (obnovuje job fn_fill_forecast_accuracy).
-- Zrychlení GET /plan/current a plánování (canonical PV forecast).
alter table ems.site_pv_forecast_calibration
add column if not exists delta_profile_cache jsonb null,
add column if not exists delta_profile_cached_at timestamptz null;
comment on column ems.site_pv_forecast_calibration.delta_profile_cache is
'Poslední JSON z fn_pv_forecast_delta_profile (120d lookback, now); NULL = ještě nepočítáno.';
comment on column ems.site_pv_forecast_calibration.delta_profile_cached_at is
'Čas posledního refresh cache (fn_refresh_site_pv_delta_profile_cache).';
create index if not exists idx_planning_run_site_comparison_of
on ems.planning_run (
site_id,
((solver_params->>'comparison_of_run_id')::int),
created_at desc
)
where status = 'comparison';
comment on index ems.idx_planning_run_site_comparison_of is
'Rychlé nalezení comparison runu pro GET /plan/compare (comparison_of_run_id v solver_params).';