Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize sites list query #537

Merged
merged 1 commit into from
Nov 14, 2024
Merged

Conversation

mvandenburgh
Copy link
Member

Moves the color_code subquery to a separate query to avoid a slow subquery in the main query, due to the
EvaluationBroadAreaSearchDetection table being extremely large. The number of sites in an evaluation run is small enough that it's feasible to load the site_id->color_code mapping into memory and manually join it with the sites_list in Python.

Moves the color_code subquery to a separate query to avoid a slow
subquery in the main query, due to the
EvaluationBroadAreaSearchDetection table being extremely large.
The number of sites in an evaluation run is small enough that it's
feasible to load the site_id->color_code mapping into memory and
manually join it with the sites_list in Python.
@mvandenburgh mvandenburgh marked this pull request as ready for review November 14, 2024 16:50
@@ -697,6 +697,7 @@ def get_sites_query(model_run_id: UUID4):
sites=JSONBAgg(
JSONObject(
id='pk',
site_id='site_id',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this setting this to the literal string 'site_id' or is it automatically doing F('site_id')?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's automatically doing F('site_id'). I thought the same thing when I saw id='pk'.

@mvandenburgh mvandenburgh merged commit f55cb0c into main Nov 14, 2024
8 checks passed
@mvandenburgh mvandenburgh deleted the optimize-scoring-sites-list-query branch November 14, 2024 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants