-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
Resource units (RUs) used should be computable from the output of EXPLAIN
and EXPLAIN ANALYZE
#47269
Comments
@nolouch PTAL. |
We support using EXPLAIN ANALYZE to display RU statistical information: #42080 |
Yep - but you can't figure out how the RUs were computed from the explain plan. It's a black box - this issue is about adding the information needed to a) verify the RU computation, and b) see what factors (reads, batch reads, bytes read, writes, bytes written, CPU ms) make up the RU. |
@adamf-db Actually, the main factors are already displayed in |
@nolouch I want to have a good mental model for future queries, and I want to be able to predict the impact of RGs/RU usage on my queries. I also want to just prove that the my QPS -> RU usage -> RG settings make sense. How do For example, given:
How do we end up with 0.329460 RUs? |
@adamf-db If you are using 7.1. x, the calculation is sum
and according to https://github.com/tikv/pd/blob/aeb259335644d65a97285d7e62b38e7e43c6ddca/client/resource_group/controller/config.go#L58C19-L67, it's a read request, and
so RU is:
|
Thanks! How does the calculation work for the below plan?
|
@adamf-db Same as the formula(7.1) above:
|
Thanks! Opened pingcap/docs#14956 to update the docs with this information. |
Closing now that there's a PR for the docs to have this information. |
Feature Request
Is your feature request related to a problem? Please describe:
I'd like to be know how the RUs reported by
EXPLAIN
andEXPLAIN ANALYZE
where calculated. Right now, it's not possible to use the output of anEXPLAIN ANALYZE
to determine why the RUs are what they are.Describe the feature you'd like:
The output of
EXPLAIN ANALYZE...
should include the counts for reads, batch reads, and CPU time. Ideally, this would be done for all operators including sub operators. This should also report the base cost values used.Basically, I want to be able to do the calculations in
tikv/pd/client/resource_manager/model.go
&config.go
but using the output ofEXPLAIN ANALYZE
(or estimated inEXPLAIN
).Describe alternatives you've considered:
There's not really any other way.
Teachability, Documentation, Adoption, Migration Strategy:
I think it's reasonable to want to understand the cost of a query you issue, and especially when you are trying to map something like QPS-> RUs -> resource groups. It's very hard to do that right now.
Examples of current output from
EXPLAIN ANALYZE format = tidb_json
with theexecuteInfo
blocks also JSON:The below is a select that partially hits a composite index:
The text was updated successfully, but these errors were encountered: