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

DM-49296: Set SQLite constant_rows_max, and use it in join_data_coordinates. #1164

Merged
merged 2 commits into from
Mar 8, 2025

Conversation

TallJimbo
Copy link
Member

@TallJimbo TallJimbo commented Mar 7, 2025

With QG generation now relying heavily on join_data_coordinates, we were hitting this limit sometimes.

Checklist

  • ran Jenkins
  • added a release note for user-visible changes to doc/changes
  • (if changing dimensions.yaml) make a copy of dimensions.yaml in configs/old_dimensions

With QG generation now relying heavily on join_data_coordinates, we
were hitting this limit sometimes.
Copy link

codecov bot commented Mar 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.36%. Comparing base (31a8d53) to head (1ffefbe).
Report is 3 commits behind head on main.

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1164   +/-   ##
=======================================
  Coverage   89.36%   89.36%           
=======================================
  Files         367      367           
  Lines       49546    49548    +2     
  Branches     6016     6016           
=======================================
+ Hits        44275    44277    +2     
  Misses       3852     3852           
  Partials     1419     1419           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@andy-slac andy-slac left a comment

Choose a reason for hiding this comment

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

Looks OK, one question.

Comment on lines +401 to +405
def get_constant_rows_max(self) -> int:
# Docstring inherited.
# This is the default SQLITE_MAX_COMPOUND_SELECT (see
# https://www.sqlite.org/limits.html):
return 500
Copy link
Contributor

Choose a reason for hiding this comment

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

The default one (in Database) is 100, does it mean Postgres limit is lower than SQLite?

Copy link
Member Author

Choose a reason for hiding this comment

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

There's no limit for this specifically listed on the PostgreSQL limits doc page, so I suspect the de facto PostgreSQL limit one on total SELECT statement size or number of bind parameters. Keeping the limit really low here means we make temporary tables more often, which might be less efficient than we could be, but it guards pretty effectively against blowing one of those limits with really wide rows.

Or, in other words, "I don't think we know what we should set it to, but performance is okay with this."

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm just surprised that you are reducing DirectQueryDriver._constant_rows_limit to 500 for SQLite and to 100 for Postgres. Before this change it was 1000 for both. My guess is that you hit 500 limit in SQLite tests, but does it also need much lower Postgres limit?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, that's a good point, when you put it that way, and all of my testing with PostgreSQL was with the 1000-row limit before I made this change. I think I will go change the default to that, as I think that's still plenty conservative enough.

@TallJimbo TallJimbo merged commit cf779c4 into main Mar 8, 2025
22 checks passed
@TallJimbo TallJimbo deleted the tickets/DM-49296 branch March 8, 2025 04:07
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.

2 participants