tidb icon indicating copy to clipboard operation
tidb copied to clipboard

parser: allow drop stats of multiple tables

Open YangKeao opened this issue 2 years ago • 3 comments

Signed-off-by: YangKeao [email protected]

What problem does this PR solve?

Issue Number: close #37872

Problem Summary:

DROP STATS doesn't allow dropping stats of multiple tables now.

What is changed and how it works?

This PR modifies the parser and executors to allow dropping multiple tables without partitions.

The grammar should be discussed, as the DROP STATS t1, t2 GLOBAL and DROP STATS t PARTITION xxx is not consistent now. I'm not sure whether it's expected, or I shouldn't allow dropping multiple tables with GLOBAL at the end?

Check List

Tests

  • [x] Unit test
  • [x] Integration test
  • [ ] Manual test (add detailed scripts or steps below)
  • [ ] No code

Release note

Allow dropping stats of multiple tables

YangKeao avatar Sep 21 '22 07:09 YangKeao

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • mjonss
  • xhebox

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment. After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review. Reviewer can cancel approval by submitting a request changes review.

ti-chi-bot avatar Sep 21 '22 07:09 ti-chi-bot

The grammar should be discussed, as the DROP STATS t1, t2 GLOBAL and DROP STATS t PARTITION xxx is not consistent now. I'm not sure whether it's expected, or I shouldn't allow dropping multiple tables with GLOBAL at the end?

My short answer: Only allow DROP STATS t[,t2[...]]. No need to handle GLOBAL (always table/global level) or PARTITION (since we want to always have table/global stats and all partitions)

I have a patch for always enabling GLOBAL stats for partitioned tables here, which I also see as a part of this discussion :)

Due to the plans of removing static partition prune mode, I would prefer that we also deprecating the support of partition specific configuration of statistics, and not adding support of dropping stats for a specific partition.

Unless there are plans to change the statistic usage for partitioned tables under dynamic prune mode?

I propose that we only support ANALYZE table (global) with non-default configuration (like buckets, samples etc.) and only saves the configuration on table/global level.

My reasoning is that the partition level statistics is aggregated to table/global level and should not differ in configuration which may result in issues when calculating the table/global statistic.

Meaning the following syntax should be supported: ANALYZE TABLE <list of tables> ... No change. ANALYZE TABLE <partitioned table> PARTITION <list of partitions> [INDEX <list of indexes>] No additional configuration allowed or used, but still allowed to update the statistics from a subset of partitions. ALTER TABLE <partitioned table> ANALYZE PARTITION <list of partitions> [INDEX <list of indexes> No additional configuration allowed or used, but still allowed to update the statistics from a subset of partitions. DROP STATS <list of tables> (no mentioning of partitions allowed or supported)

And this would be deprecated: ANALYZE TABLE <partitioned table> PARTITION <list of partitions> AllColumnsOrPredicateColumnsOpt AnalyzeOptionListOpt ALTER TABLE <partitioned table> ANALYZE PARTITION <list of partitions> AllColumnsOrPredicateColumnsOpt AnalyzeOptionListOpt ANALYZE INCREMENTAL TABLE <partitioned table> PARTITION... ANALYZE TABLE <partitioned table> PARTITION <list of partitions> COLUMNS...

mjonss avatar Sep 21 '22 08:09 mjonss

My short answer: Only allow DROP STATS t[,t2[...]]. No need to handle GLOBAL (always table/global level) or PARTITION (since we want to always have table/global stats and all partitions)

@mjonss Good answer! IIUC, DROP STATS ... GLOBAL and DROP STATS ... PARTITION ... will be deprecated? In the latest update of this patch, I add warnings for these two syntax, and don't touch the function of them (before they are useless). In conclusion, this PR becomes the following change:

  1. Deprecate the DROP STATS ... GLOBAL and DROP STATS ... PARTITION ... syntax
  2. Allow dropping stats for multiple tables through DROP STATS a,b,c,d

PTAL

YangKeao avatar Sep 22 '22 08:09 YangKeao

@YangKeao: PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

ti-chi-bot avatar Oct 01 '22 09:10 ti-chi-bot

@YangKeao rebase please, let us merge it.

xhebox avatar Nov 11 '22 10:11 xhebox

/merge

xhebox avatar Nov 14 '22 05:11 xhebox

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

Commit hash: bebee8b183212429a78dc8b5de8da05b3172bf73

ti-chi-bot avatar Nov 14 '22 05:11 ti-chi-bot

@YangKeao Rebase please. Also, don't forget pingcap/doc changes.

I have updated the documents in https://github.com/pingcap/docs-cn/pull/11986 and https://github.com/pingcap/docs/pull/11287. Could you please tech-review these documents? @mjonss @xhebox . I only update the syntax (following the DROP TABLE ... style, didn't add more examples about dropping multiple tables). The DROP STATS ... PARTITION ... and DROP STATS ... GLOBAL are not updated there, because they are deprecated (though, have never been on the documents).

YangKeao avatar Nov 14 '22 06:11 YangKeao

TiDB MergeCI notify

🔴 Bad News! New failing [1] after this pr merged. These new failed integration tests seem to be caused by the current PR, please try to fix these new failed integration tests, thanks!

CI Name Result Duration Compare with Parent commit
idc-jenkins-ci-tidb/mybatis-test 🟥 failed 1, success 0, total 1 11 min New failing
idc-jenkins-ci-tidb/integration-ddl-test 🔴 failed 1, success 5, total 6 44 min Existing failure
idc-jenkins-ci/integration-cdc-test ✅ all 39 tests passed 19 min Fixed
idc-jenkins-ci-tidb/integration-common-test 🟢 all 17 tests passed 13 min Existing passed
idc-jenkins-ci-tidb/common-test 🟢 all 11 tests passed 10 min Existing passed
idc-jenkins-ci-tidb/sqllogic-test-2 🟢 all 28 tests passed 6 min 41 sec Existing passed
idc-jenkins-ci-tidb/tics-test 🟢 all 1 tests passed 6 min 32 sec Existing passed
idc-jenkins-ci-tidb/sqllogic-test-1 🟢 all 26 tests passed 5 min 34 sec Existing passed
idc-jenkins-ci-tidb/integration-compatibility-test 🟢 all 1 tests passed 2 min 43 sec Existing passed
idc-jenkins-ci-tidb/plugin-test 🟢 build success, plugin test success 4min Existing passed

sre-bot avatar Nov 14 '22 07:11 sre-bot