tidb icon indicating copy to clipboard operation
tidb copied to clipboard

use plan cost to spot expensive query

Open eurekaka opened this issue 8 years ago • 2 comments

Feature Request

Is your feature request related to a problem? Please describe:

Currently, isPhysicalPlanExpensive uses row count of each plan node to determine whether this plan is expensive. For cases like index look up join, if inner table is huge, but the join condition is equal expression on handle, this index join should not be as that expensive as the row count of inner table indicates.

Describe the feature you'd like:

Should we record cost in each plan node and use this cost to decide whether the plan is expensive or not?

Teachability, Documentation, Adoption, Migration Strategy:

A concern for this proposal is that the cost threshold can be something hard to understand and decide for DBA.

eurekaka avatar Sep 28 '18 04:09 eurekaka

In release 3.0, TiDB prints an expensive query log based on the runtime performance:

  • if the query runs longer than @@tidb_expensive_query_time_threshold(1 minutes by default), it prints an expensive log
  • if the query uses more than memory quota for a query, it also prints an expensive log.

zz-jason avatar Mar 17 '20 15:03 zz-jason

It's more accurate than the method proposed in this issue. I think we can close this issue for now. Feel free to reopen it if you have other concerns.

zz-jason avatar Mar 17 '20 15:03 zz-jason