-
Notifications
You must be signed in to change notification settings - Fork 6
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
Improve IAMC endpoint query performance #56
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
But is there a way to write a test for the new behavior, to ensure that the timeseries-row is indeed deleted (but only if all datapoints are removed).
Good point, i added a check to |
…/ixmp4 into improvement/iamc-query-performance
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, looks great!
In use some performance problems have been identified with the iamc endpoints in some production databases.
The culprits seem to be queries like this:
If the
iamc_datapoint
table is very big this query takes quite a long time. A simple fix i found was to use a subquery instead of a join:This is about x10 faster on my dataset, but still not ideal. The optimization i went with was the following:
First add some custom logic to the datapoint deletion: When datapoints are deleted, orphaned timeseries rows should be deleted. That way i can completely avoid the join on the
iamc_datapoints
table and just join the timeseries table:Query time is down to 300ms from 10s :)
This PR also adds test for the backend repository
count
function.