sql: request statement bundle with min duration #65451
Labels
C-enhancement
Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)
O-postmortem
Originated from a Postmortem action item.
Is your feature request related to a problem? Please describe.
When someone requests a statement bundle, more often than not they want to capture a particularly slow query. However, if only a small fraction of the queries is slow (say, there is a single contended row in a table but a lot of traffic does not hit that row), the statement bundle in all likelihood will not manage to capture the query with parameters of interest.
Describe the solution you'd like
When requesting the statement bundle, I would like to specify a time threshold which the captured query is guaranteed to have exceeded.
Describe alternatives you've considered
While this is possible to implement, it's possibly difficult to implement efficiently. As long as the queries that are traced are chosen "randomly", it is very rare to hit the interesting case. As a result, with this feature added, statement bundles would simply take a very long time to become available, but it is also important that we don't have to wait for too long. Tracing all incarnations of the statement, on the other hand, comes with a performance cost since verbose tracing is expensive.
Possibly a solution could be to unconditionally enable non-verbose tracing for the statement and turn on the verbosity when the threshold is met. This would result in a partial verbose trace (a prefix of messages is missing) but this may be acceptable as long as it is clearly indicated (via a message); this can also independently occur for any trace since traces control their memory footprint by evicting old messages anyway.
Additional context
https://github.com/cockroachlabs/support/issues/973
The text was updated successfully, but these errors were encountered: