Skip to content

core: lazy reload analyze stats with mvcc#7438

Open
pereman2 wants to merge 3 commits into
tursodatabase:mainfrom
pereman2:analyze-mvcc
Open

core: lazy reload analyze stats with mvcc#7438
pereman2 wants to merge 3 commits into
tursodatabase:mainfrom
pereman2:analyze-mvcc

Conversation

@pereman2

Copy link
Copy Markdown
Collaborator

From clanker: Under MVCC, the ANALYZE-stats loader ran before the schema it needed existed and never ran again, so the optimizer planned every query with zero statistics — and one cost-model tie later, a point-delete became a 10,000-row scan that dominated both the latency floor and the contention abort storm.

I have 0 idea about how analyze works currently but this indeed fixed problems with analyze and mvcc

Comment thread core/stats.rs Outdated
if stats.tables.is_empty() {
return;
}
let mut with_stats = (*schema).clone();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

doing two deep clones of the schema here is gonna be hella expensive... I'm looking to see if we can get around this somehow

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Actually yeah let's just move the AnalyzeStats out of the Schema and then we can atomic swap them. I will push to this branch

@PThorpe92

Copy link
Copy Markdown
Collaborator

simulator run fails on main 😢 so unfortunately unrelated to these changes

@codspeed-hq

codspeed-hq Bot commented Jun 11, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 638 untouched benchmarks
⏩ 105 skipped benchmarks1


Comparing pereman2:analyze-mvcc (4083ff4) with main (f522fc6)

Open in CodSpeed

Footnotes

  1. 105 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants