Only retrieve updated query statement metrics #19321
Draft
+126
−12
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Updates MySQL statement collection to only gather statements that have executed since the last collection. This functionality is behind a flag to allow for slow rollout and testing before hopefully making it standard.
Four variant builds were compared:
Testing was performed on orders app with 1 minute bursts of high cardinality queries every 5 minutes.
Somewhat surprisingly, querying for the digest and then for digest text made little difference in performance, even with large random statements (~1kb) executed during bursts. When querying for only updated rows, the much smaller row count allows for fetching the text as well, avoiding a second database query.
CPU usage is greatly reduced during normal load, and somewhat reduced during high cardinality bursts.
Query time and overall statement metrics collection time (note that y-axis is in seconds, not ms) are greatly reduced.
Motivation
Customers have complained about CPU usage by the MySQL check. This change uses a similar technique to the other database integrations to minimize the amount of unnecessary data retrieved for each statement collection.
Review checklist (to be filled by reviewers)
qa/skip-qa
label if the PR doesn't need to be tested during QA.backport/<branch-name>
label to the PR and it will automatically open a backport PR once this one is merged