-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
sql: add full table or index scan count metric #59261
sql: add full table or index scan count metric #59261
Conversation
2fb51dd
to
6b979fd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! I have some nits, but the code looks good to me in general.
Reviewed 4 of 4 files at r1.
Reviewable status:complete! 0 of 0 LGTMs obtained (waiting on @barryhe2000)
pkg/sql/conn_executor.go, line 298 at r1 (raw file):
func makeMetrics(internal bool) Metrics { // fullTableIndexScan is only instantiated for non-internal queries
nit: missing period.
pkg/sql/conn_executor_exec.go, line 917 at r1 (raw file):
flags := planner.curPlan.flags // We don't execute the statement if:
nit: this comment should be moved below, to right before returning an error that stops the statement execution.
pkg/sql/exec_util.go, line 478 at r1 (raw file):
} MetaFullTableOrIndexScan = metric.Metadata{ Name: "sql.full.table.index.scan.count",
nit: I think I'd use sql.full_index_scan.count
("full table" scan is a "full primary index" scan) or just sql.full_scan.count
. Maybe @jordanlewis or @asubiotto have a better suggestion.
pkg/sql/executor_statement_metrics.go, line 143 at r1 (raw file):
FailureCount *metric.Counter // FullTableOrIndexScanCount counts the number of full table or index scans.
nit: I'd mention that it is only for user-initiated queries.
6b979fd
to
3c15c39
Compare
Fixed the nits that you mentioned @yuzefovich |
Nice! Did you manage to find a testing strategy for metrics? |
Mind posting a sample output for a workload that we know about--say TPC-C? |
Do we wanna add a dashboard for this metric? I initially thought it wasn't necessary since I assumed that the full table/index scan info is useful only during the debugging, but I'm not sure whether that assumption is correct - it might make sense to have a dashboard for it at the very bottom of |
I'm not convinced it's useful as a |
I think what @awoods187 is saying though, is if we could see the output of this graph (regardless of where it ends up being) for a sample workload. |
I actually think we should add this as a chart in the DB Console. Operators often want some measurement of how many scans are occurring at the cluster level--in many cases full table scans are the best option so I wouldn't expect this metric to be zero. I like the way it looks in the custom chart and think we should keep this metric at the bottom of SQL reports. |
OK. In that case, @barryhe2000 note that you probably want to use a non-negative rate option so the timeseries doesn't show the count since the beginning of time, rather the count in a given time interval. |
3c15c39
to
2bba3cb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are now 4 commits in this PR, we should clean that up so that only one commit remains.
Reviewed 5 of 5 files at r5.
Reviewable status:complete! 0 of 0 LGTMs obtained (waiting on @barryhe2000)
pkg/sql/conn_executor.go, line 904 at r5 (raw file):
// distSQLMetrics contains distributed metrics to be accounted for. distSQLMetrics *execinfra.DistSQLMetrics
This is no longer needed.
4922203
to
c12c4d3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 1 files at r6.
Reviewable status:complete! 1 of 0 LGTMs obtained (waiting on @barryhe2000)
2195d3a
to
0e35a0f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 1 files at r7.
Reviewable status:complete! 0 of 0 LGTMs obtained (and 1 stale)
ef17e1f
to
a79a8c5
Compare
bors r+ |
🕐 Waiting for PR status (Github check) to be set, probably by CI. Bors will automatically try to run when all required PR statuses are set. |
GitHub status checks took too long to complete, so bors is giving up. You can adjust bors configuration to have it wait longer if you like. |
bors r- Hm, I'm guessing the bors is complaining about the license/cla check. Also, I see that you added the chart - I think we discussed putting it at the very bottom of the SQL dashboard, and currently it's in the middle. |
CI was failing a test because the chart wasn't there, I can move it. Is there anything doable about the license/cla check? Not sure why it isn't passing |
This new metric allows for users to see a time series of their full table or index scans in the advanced debug console. This metric is part of EngineMetrics, so there's a corresponding internal metric that counts internal full table or index scans from internal engine queries. Release note (ui change): User can see time series of full table or index scans in advanced debug console.
a79a8c5
to
ac3b3c7
Compare
bors r+ |
Build failed (retrying...): |
Build succeeded: |
Previously, this metric was not available, but is now added so that users can
see when full table scans or full index scans are being used for their queries.
Fixes: #58653
Release note (ui change): User can see time series custom chart in admin ui
for full table or index scans.