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

Count queries are expensive #605

Closed
marxide opened this issue Feb 1, 2022 · 1 comment · Fixed by #676
Closed

Count queries are expensive #605

marxide opened this issue Feb 1, 2022 · 1 comment · Fixed by #676
Assignees
Labels
python Pull requests that update Python code

Comments

@marxide
Copy link
Contributor

marxide commented Feb 1, 2022

The web interface executes several queries to display some counts. On the index page, these include the number of runs, images, measurements, and sources. Similar counts are run on other pages too, such as the run detail page.

Given the size of our database, these queries can be expensive to run. The index page count queries can take longer than a minute to complete before serving the page to the user.

These counts are not important – they're just nice to have. We should remove or optimize them. One easy optimization would be to calculate the counts at the end of a run and store them in the Run model. Then, to display the counts, we only need to query for the stored counts rather than count the relevant rows in the database tables.

@marxide marxide added the python Pull requests that update Python code label Feb 1, 2022
@marxide marxide self-assigned this Feb 1, 2022
@marxide
Copy link
Contributor Author

marxide commented Feb 1, 2022

Some of the counts are already stored in the Run model, but summing the measurement counts for all Run objects will count many measurements more than once as measurements can belong to more than one run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
python Pull requests that update Python code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant