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

statistics: build global statistics for table partition #18717

Closed
wants to merge 4 commits into from
Closed

statistics: build global statistics for table partition #18717

wants to merge 4 commits into from

Conversation

lysu
Copy link
Contributor

@lysu lysu commented Jul 21, 2020

What problem does this PR solve?

Issue Number: ref #18551

Problem Summary:

to support planner select index before pruning

What is changed and how it works?

What's Changed:

  • full analyze build ranges for all partition in a table and collect stats as one table(make columns or unique index stats works)
  • make planner query stats by tableID instead of partitionID when it's new version partition table
  • handle non-unique index stats in the partition table
  • handle incremental analyze
  • handle fast analyze
  • handle feedback
  • make show/export/import works well
  • fix cut-over problem

How it Works:

Related changes

  • n/a

Check List

Tests

  • Unit test
  • Integration test
  • Manual test

Side effects

  • n/a

Release note

  • No release note.

This change is Reviewable

@codecov
Copy link

codecov bot commented Aug 5, 2020

Codecov Report

Merging #18717 into master will increase coverage by 0.1866%.
The diff coverage is 85.2842%.

@@               Coverage Diff                @@
##             master     #18717        +/-   ##
================================================
+ Coverage   79.0545%   79.2412%   +0.1866%     
================================================
  Files           546        546                
  Lines        148433     148313       -120     
================================================
+ Hits         117343     117525       +182     
+ Misses        21614      21289       -325     
- Partials       9476       9499        +23     

@lysu
Copy link
Contributor Author

lysu commented Aug 7, 2020

/run-all-tests

@lysu lysu marked this pull request as ready for review August 7, 2020 06:21
@lysu lysu requested review from a team as code owners August 7, 2020 06:21
@lysu lysu requested review from qw4990 and hanfei1991 and removed request for a team August 7, 2020 06:21
@lysu lysu removed the status/WIP label Aug 7, 2020
@lysu lysu requested review from tiancaiamao and winoros and removed request for hanfei1991 August 7, 2020 07:31
ddl/ddl_api.go Outdated
func handleTableOptions(options []*ast.TableOption, tbInfo *model.TableInfo) error {
func handleTableOptions(ctx sessionctx.Context, options []*ast.TableOption, tbInfo *model.TableInfo) error {
if !tryOldPartitionImplementation(ctx) && tbInfo.Partition != nil && len(tbInfo.Partition.Definitions) > 0 {
tbInfo.IsNewPartition = true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why store this info?

Copy link
Contributor Author

@lysu lysu Aug 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

emmm..we need one method to cut off old stats to new stats...

current code chooses new partition tables use new stats and old partition tables use old stats, and add IsNewPartition flag to mark it...maybe we need more discuss about how to "switch old stats to new stats" or "switch old partition to new partition"

tryOldPartitionImplementation at here, just make test can run test in both new/old stats format.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tryOldPartitionImplementation is a runtime flag.
I mean, do we have to persistent the flag in the model.TableInfo? That flag is stored in the storage, and may bring compatible issue.

distsql/request_builder.go Outdated Show resolved Hide resolved
executor/infoschema_reader_test.go Outdated Show resolved Hide resolved
statistics/handle/ddl.go Outdated Show resolved Hide resolved
@lysu
Copy link
Contributor Author

lysu commented Aug 13, 2020

@tiancaiamao this pr became too large, I will split it tody - -~

TableReader_7 10.00 root partition:all data:Selection_6
└─Selection_6 10.00 cop[tikv] eq(test.th.a, -2)
└─TableFullScan_5 10000.00 cop[tikv] table:th keep order:false, stats:pseudo
TableReader_7 1.00 root partition:all data:Selection_6
Copy link
Contributor Author

@lysu lysu Aug 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we cannot get a stable est count after change to global status that range query using sample based column histogram.
(before this pr it's full tablescan and can use table count directly)

so need improve explain test firstly - -

@lysu
Copy link
Contributor Author

lysu commented Aug 17, 2020

/run-all-tests tikv=pr/8443

@lysu
Copy link
Contributor Author

lysu commented Aug 17, 2020

/run-integration-ddl-test tikv=pr/8443

@lysu lysu marked this pull request as draft September 1, 2020 11:28
@lysu
Copy link
Contributor Author

lysu commented Sep 2, 2020

/rebuild

@lysu
Copy link
Contributor Author

lysu commented Sep 3, 2020

/run-unit-test

@lysu
Copy link
Contributor Author

lysu commented Sep 3, 2020

/run-all-tests

@lysu
Copy link
Contributor Author

lysu commented Sep 3, 2020

/run-integration-compatibility-test

@lysu
Copy link
Contributor Author

lysu commented Sep 3, 2020

/run-all-tests

@lysu
Copy link
Contributor Author

lysu commented Sep 3, 2020

/run-check_dev_2

@lysu
Copy link
Contributor Author

lysu commented Sep 10, 2020

/run-all-tests tidb-test=pr/1086

@qw4990 qw4990 removed their request for review September 11, 2020 06:24
@lysu
Copy link
Contributor Author

lysu commented Sep 25, 2020

/run-all-tests

1 similar comment
@lysu
Copy link
Contributor Author

lysu commented Sep 25, 2020

/run-all-tests

@lysu
Copy link
Contributor Author

lysu commented Sep 25, 2020

/run-check_dev_2

@lysu
Copy link
Contributor Author

lysu commented Sep 27, 2020

/test-check_dev_2

@lysu
Copy link
Contributor Author

lysu commented Sep 27, 2020

/run-all-tests

@lysu
Copy link
Contributor Author

lysu commented Sep 28, 2020

/run-all-tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants