speedup srovnani
Some checks failed
CI and deploy / migration-check (push) Failing after 11s
CI and deploy / deploy (push) Has been skipped

This commit is contained in:
Dusan Vojacek
2026-04-27 20:09:40 +02:00
parent 542cd9a73c
commit e35110cb87
5 changed files with 195 additions and 149 deletions

View File

@@ -0,0 +1,16 @@
-- Zrychlení fn_pv_forecast_delta_profile (volá ho pv-slots-corrected): range scan site + interval_start
-- s podmínkami učení bez sekvenčního full scanu větší historie.
create index if not exists idx_forecast_accuracy_site_interval_delta_profile
on ems.forecast_accuracy (
site_id,
interval_start desc,
pv_array_id,
forecast_created_at desc
)
where actual_power_w is not null
and coalesce(learning_eligible, true) = true
and forecast_created_at <= interval_start;
comment on index ems.idx_forecast_accuracy_site_interval_delta_profile is
'Partial index pro výběr posledního forecast runu na slot (DISTINCT ON interval_start, pv_array_id) v delta profilu.';

View File

@@ -0,0 +1,8 @@
-- Plán „nejnovější run na slot“ často sahá po forecast_pv_interval přes (run_id, interval).
-- Druhý pořádek (pole → čas) pomáhá alternativním plánům při filtru pv_array_id + časové okno.
create index if not exists idx_forecast_pv_interval_pv_array_interval_start
on ems.forecast_pv_interval (pv_array_id, interval_start desc);
comment on index ems.idx_forecast_pv_interval_pv_array_interval_start is
'Podpora dotazů s filtrem na pv_array_id a rozsah interval_start (pv-slots, DISTINCT ON).';