Add SQL diagnosis rule: SQL plan changed and execution is slowed down notably #17928
Labels
good first issue
Denotes an issue ready for a new contributor, according to the "help wanted" guidelines.
help wanted
Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.
type/enhancement
The issue or PR belongs to an enhancement.
Introduce
If the SQL plan was changed, and the execution is slowed down notably, It may be caused by the statistics was not accurate or something else( such as a bug of TiDB 😢 ).
Task1
First, we can find the SQL of the plan changed and execution is slowed down notably, Then append a warning in the
INSPECTION_RESULT
table.How to find the SQL of the plan changed?
cluster_statements_summary
andcluster_statements_summary_history
.cluster_slow_query
:Should query different table according to the diagnosis time range:
cluster_statements_summary
andcluster_statements_summary_history
only contain the recent data, so if the diagnosis time range is in thecluster_statements_summary
orcluster_statements_summary_history
, we can only query the table, otherwise, should query from thecluster_slow_query
.After find out the SQL of the plan changed, we also need to make sure the execution is slowed down notably, such as
t1/t2 >= 2
.If the result was too much, I think we should also need to add a limit to this.
Task2
After task1 find out the SQL of the plan changed, maybe we can give more advice such as:
analyze table ...
timely or use Plan bindingRefer
configInspection
implementation in TiDB.If you have any questions or want to discuss something, you can chat in the sig-dashboard slack channel and @
chenshuang
.The text was updated successfully, but these errors were encountered: