Skip to content

Test larger batches with more efficient queries for datastore export#1377

Draft
dhirving wants to merge 3 commits into
mainfrom
u/dhirving/optimize-datastore-export
Draft

Test larger batches with more efficient queries for datastore export#1377
dhirving wants to merge 3 commits into
mainfrom
u/dhirving/optimize-datastore-export

Conversation

@dhirving
Copy link
Copy Markdown
Contributor

@dhirving dhirving commented May 19, 2026

This reduces export time for butler_transform by about 30-40%, but only when using psycopg3. We're still on psycopg2, though psycopg3 will become the default in the next version of sqlalchemy.

psycopg2 never uses bind parameters, so it still generates a large new query for each execution. With psycopg3 it 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

  • ran Jenkins
  • added a release note for user-visible changes to doc/changes
  • (if changing dimensions.yaml) make a copy of the updated dimensions.yaml in configs/old_dimensions and update the list in doc/lsst.daf.butler/dimensions.rst

dhirving added 3 commits May 18, 2026 16:21
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
Copy link
Copy Markdown

codecov Bot commented May 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.62%. Comparing base (4a958a8) to head (a4df221).
⚠️ Report is 3 commits behind head on main.
✅ All tests successful. No failed tests found.

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.
📢 Have feedback on the report? Share it here.

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.

1 participant