Test larger batches with more efficient queries for datastore export#1377
Draft
dhirving wants to merge 3 commits into
Draft
Test larger batches with more efficient queries for datastore export#1377dhirving wants to merge 3 commits into
dhirving wants to merge 3 commits into
Conversation
Reduce the number of queries required to look up large quantities of datastore records by 50x. The query now also uses `= ANY(?)` instead of `IN(?, ?, ... , ?)` to use a single array parameter. This bypasses the Postgresql bind parameter limit and reduces query parsing overhead.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1377 +/- ##
=======================================
Coverage 89.62% 89.62%
=======================================
Files 373 373
Lines 50772 50792 +20
Branches 5913 5914 +1
=======================================
+ Hits 45502 45521 +19
Misses 3880 3880
- Partials 1390 1391 +1 ☔ View full report in Codecov by Sentry. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This reduces export time for
butler_transformby about 30-40%, but only when usingpsycopg3. We're still onpsycopg2, thoughpsycopg3will become the default in the next version of sqlalchemy.psycopg2never uses bind parameters, so it still generates a large new query for each execution. Withpsycopg3it uses a single bind parameter for the list of dataset IDs, and it is able to cache and re-use the query, and use a more efficient binary encoding for sending the UUIDs.Checklist
doc/changesconfigs/old_dimensionsand update the list indoc/lsst.daf.butler/dimensions.rst