forked from cockroachdb/cockroach
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sqlstats: reuse the temporary statement stats container
This commit cleans up the confusing swapping and uses of the 2 fields on the StatsCollector, `ApplicationStats` and `flushTarget`. The original purpose of `flushTarget` seems to have been for explicit transactions, where we would need to use a temp container to record statement stats and flush them to the app container at the end of transaction execution in order to correlate the txn fingerprint id. The assumption then was that implicit transactions have 1 statement, thus we'd only need to use a flush target for explicit transactions - for implicit txns we could get away with using the `ApplicationStats` field directly. Before: If implict txn: - do nothing, stats will be recorded to `ApplicationStats` directly If explicit txn: - set `flushTarget` as `ApplicationStats`, allocate temp container for `ApplicationStats` where the txn's statements will be recorded - on txn finish, flush `ApplicationStats` to `flushTarget`, set `ApplicationStats` to `flushTarget`. Eventually we corrected that assumption and are now separating the current transacion's statements and the flushTarget for every execution. There's no need to perform the little dance above, and we're likely not managing our statement stats container as efficiently as we could be. Now: - `FlushTarget` is always defined for a stats collector. It represents the current application's sql stats - `ApplicationStats` is renamed to `activeTxnStatementStats` to reflect that it is use to store the current transaction's statement stats - Instead of allocating a new container for the current transaction each time, we'll clear and reuse `activeTxnStatementStats` Fixes: cockroachdb#94650
- Loading branch information
Showing
3 changed files
with
18 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters