Skip to content

{179579733}: fix sql query plan worse for parameter binding#5948

Open
emelialei88 wants to merge 1 commit into
bloomberg:mainfrom
emelialei88:fix/sqlite-prepare-slow
Open

{179579733}: fix sql query plan worse for parameter binding#5948
emelialei88 wants to merge 1 commit into
bloomberg:mainfrom
emelialei88:fix/sqlite-prepare-slow

Conversation

@emelialei88
Copy link
Copy Markdown
Contributor

In whereLoopOutputAdjust, we call sqlite3ExprIsInteger to adjust output number estimation for small numbers like -1, 0, 1. We always pass in 0 as the third parameter. The function would estimate based on the real value for literal values but skipped sqlite3VdbeGetBoundValue since pParse==0. This could cause the query planner to choose a significantly worse plan when using bound parameters vs literals.

Fix has been made on upstream sqlite branch-3.28.

Copy link
Copy Markdown

@roborivers roborivers left a comment

Choose a reason for hiding this comment

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

Cbuild submission: Success ✓.
Regression testing: Success ✓.

The first 10 failing tests are:
truncatesc_offline_generated **quarantined**
cldeadlock
reco-ddlk-sql **quarantined**
consumer_non_atomic_default_consumer_generated **quarantined**

@emelialei88 emelialei88 marked this pull request as ready for review May 19, 2026 17:38
Signed-off-by: Emelia Lei <wlei29@bloomberg.net>
@emelialei88 emelialei88 force-pushed the fix/sqlite-prepare-slow branch from 8b648e6 to 3f0818b Compare May 19, 2026 20:55
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