openclimatefix / nowcasting_datamodel

Datamodel for the nowcasting project
6 stars 6 forks source link

Improve query for forecast all historic=True #237

Closed peterdudfield closed 1 year ago

peterdudfield commented 1 year ago

Detailed Description

Improve query for forecast all historic=True

Context

Possible Implementation

this function could be improves - https://github.com/openclimatefix/nowcasting_datamodel/blob/main/nowcasting_datamodel/read/read.py#L295

  1. do subquery to get forecasts with historic=True, then join with forecast_latest table
  2. Could also look at pre loading forecast_values_latest rather than forecast_values, this might speed it up
peterdudfield commented 1 year ago

adding an index on forecastsql.historic seems to help. Tried this on dev