pingcap / tidb

TiDB is an open-source, cloud-native, distributed, MySQL-Compatible database for elastic scale and real-time analytics. Try AI-powered Chat2Query free at : https://www.pingcap.com/tidb-serverless/
https://pingcap.com
Apache License 2.0
36.46k stars 5.74k forks source link

infoschema, util/stmtsummary: enhance statements_summary. #25031

Closed ClSlaid closed 3 years ago

ClSlaid commented 3 years ago

What problem does this PR solve?

Issue Number: close #24083

Problem Summary:

What is changed and how it works?

What's Changed:

before:

select * from `INFORMATION_SCHEMA`.`STATEMENTS_SUMMARY`;

output:

BEGIN_TIME ... DIGEST SCHEMA_NAME ...
2019-01-01 00:30 ... digest_2 schema_name_2 ...
2019-01-01 00:30 ... digest_1 schema_name_1 ...
2019-01-01 00:00 ... digest_0 schema_name_0 ...

statement_summary table has a fixed size, some statement digests may get kicked by other digests, leading to lose of information.

This pull request will append a special row to the statement_summary, which would sum up those statement digests got evicted from statement_summary, so that all digests' information will be recorded.

Following MySQL's behavior, the row's DIGEST and SCHEMA_NAME match no record in the table, their value is <nil>.

BEGIN_TIME ... DIGEST SCHEMA_NAME ...
2019-01-01 00:30 ... digest_2 schema_name_2 ...
2019-01-01 00:30 ... digest_1 schema_name_1 ...
2019-01-01 00:00 ... digest_0 schema_name_0 ...
2019-01-01 00:30 ... <nil> <nil> ...

Special rows corresponding to each interval will also be append to statements_summary_history table.

How it Works:

Related changes

Check List

Tests

Side effects

Release note

ti-chi-bot commented 3 years ago

This pull request has been accepted and is ready to merge.

Commit hash: ce03218e9e9a880b7ea0b87403fc960f1e4e9696

ClSlaid commented 3 years ago

/run-integration-common-test /run-check_dev_2

ti-chi-bot commented 3 years ago

@ClSlaid: Your PR was out of date, I have automatically updated it for you.

At the same time I will also trigger all tests for you:

/run-all-tests

If the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

Instructions for interacting with me using PR comments are available [here](https://prow.tidb.io/command-help). If you have questions or suggestions related to my behavior, please file an issue against the [ti-community-infra/tichi](https://github.com/ti-community-infra/tichi/issues/new?title=Prow%20issue:) repository.
ClSlaid commented 3 years ago

/run-integration-common-test