Skip to content
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

optimize query statements summary table by avoid decode plan by conditional pushdown #26379

Closed
Tracked by #24086
crazycs520 opened this issue Jul 20, 2021 · 2 comments · Fixed by #27563
Closed
Tracked by #24086
Assignees
Labels
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. type/performance

Comments

@crazycs520
Copy link
Contributor

Background

PR #25843 enlarge the tidb_stmt_summary_max_stmt_count default value to 3000. It's great for diagnose problem since the statements_summary can record more SQL. But it will also slow down the performance when query statements_summary. Mostly the reasons affecting performance is cause by DecodePlan for each row in statements_summary.

#25892 already has optimized the performance by prune column. But it doesn't optimize for the following SQL which will be used in tidb-dashboard:

select * 
from `STATEMENTS_SUMMARY` 
where 
    digest='8019af26debae8aa7642c501dbc43212417b3fb14e6aec779f709976b7e521be' 
    and 
    unix_timestamp(summary_begin_time) = 1626769800;

The upper SQL need query all columns value, so #25892 which use prune column method can't optimize it.

But we can use conditional pushdown to do optimization. As you can see the condition is digest='8019af26debae8aa7642c501dbc43212417b3fb14e6aec779f709976b7e521be' and unix_timestamp(summary_begin_time) = 1626769800. Mostly There is very little data that meets this condition, so we can use conditional pushdown to only fetch the row which meets the condition.

Reference

How to do conditional pushdown for query system table?

  • You can use MemTablePredicateExtractor to implements conditional pushdown.

You can reference the following PR which also do conditional pushdown for query system table:

mentor

If you have any questions about this issue, you can comment on this issue, I will reply you as soon as possible.

@crazycs520 crazycs520 added type/enhancement The issue or PR belongs to an enhancement. difficulty/medium help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. labels Jul 20, 2021
@TszKitLo40
Copy link
Contributor

Can I try this issue? @crazycs520

@TszKitLo40
Copy link
Contributor

/assign

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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. type/performance
Projects
None yet
3 participants