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

sqlstats: add batching to flush operation #139608

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dhartunian
Copy link
Collaborator

Previously, we would process each persisted stat row insert as a separate transaction. This incurred lots of transaction teardown/setup costs over the life of the flush operation.

This change modifies the flush to batch the inserts in groups of 100 (arbitrarily chosen, for now). The batches are iterated over using a small struct that constructs the batch slices from the list of stats. The rest of the operation remains as-is except the SQL transaction is moved upwards in the callstack to contain all the elements in a single batch.

Resolves: #139143

Release note: None

Previously, we would process each persisted stat row insert as a
separate transaction. This incurred lots of transaction teardown/setup
costs over the life of the flush operation.

This change modifies the flush to batch the inserts in groups of 100
(arbitrarily chosen, for now). The batches are iterated over using a
small struct that constructs the batch slices from the list of stats.
The rest of the operation remains as-is except the SQL transaction is
moved upwards in the callstack to contain all the elements in a single
batch.

Resolves: cockroachdb#139143

Release note: None
@dhartunian dhartunian requested a review from a team as a code owner January 22, 2025 22:52
@cockroach-teamcity
Copy link
Member

This change is Reviewable

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.

sqlstats: batch flush operation when writing persisted stats
2 participants