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

planner: respect tidb_analyze_column_options when build analyze plan #54240

Merged

Conversation

Rustin170506
Copy link
Member

@Rustin170506 Rustin170506 commented Jun 26, 2024

What problem does this PR solve?

Issue Number: ref #53567

This PR is based on #54200.

Problem Summary:

When tidb_analyze_column_options is set to PREDICATE, we should only analyze predicate columns.

What changed and how does it work?

  • Checked tidb_analyze_default_column_choice when building the analyze plan.
  • Only analyze indexes and the columns composing the indexes if there are no predicate columns.
  • Added some tests to cover the analyze plan building code.
  • Removed all use of tidb_enable_column_tracking.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. sig/planner SIG: Planner size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 26, 2024
@Rustin170506 Rustin170506 force-pushed the rustin-patch-sessionctx-stack1-analyze branch from 64d7b81 to 7bdc3c7 Compare June 26, 2024 08:36
Copy link

codecov bot commented Jun 26, 2024

Codecov Report

Attention: Patch coverage is 76.00000% with 12 lines in your changes missing coverage. Please review.

Project coverage is 56.1611%. Comparing base (184b010) to head (5a30f87).
Report is 15 commits behind head on master.

Additional details and impacted files
@@                Coverage Diff                @@
##             master     #54240         +/-   ##
=================================================
- Coverage   74.7619%   56.1611%   -18.6008%     
=================================================
  Files          1523       1645        +122     
  Lines        361410     613324     +251914     
=================================================
+ Hits         270197     344450      +74253     
- Misses        71584     245648     +174064     
- Partials      19629      23226       +3597     
Flag Coverage Δ
integration 36.3109% <10.0000%> (?)
unit 71.7921% <76.0000%> (-1.8609%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 52.9656% <ø> (-2.2339%) ⬇️
parser ∅ <ø> (∅)
br 52.6314% <ø> (+4.6677%) ⬆️

@Rustin170506 Rustin170506 force-pushed the rustin-patch-sessionctx-stack1-analyze branch from 58d2dbd to 990c0d2 Compare June 26, 2024 09:38
@Rustin170506 Rustin170506 changed the title planner: respect tidb_analyze_default_column_choice when build analyze plan planner: respect tidb_analyze_column_options when build analyze plan Jun 26, 2024
@Rustin170506 Rustin170506 force-pushed the rustin-patch-sessionctx-stack1-analyze branch 3 times, most recently from d4b15f6 to b11f780 Compare June 26, 2024 09:58
@ti-chi-bot ti-chi-bot bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 26, 2024
@Rustin170506 Rustin170506 force-pushed the rustin-patch-sessionctx-stack1-analyze branch from e5cd628 to 8efe30a Compare June 26, 2024 11:17
Copy link
Member Author

@Rustin170506 Rustin170506 left a comment

Choose a reason for hiding this comment

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

🔢 Self-check (PR reviewed by myself and ready for feedback.)


// Analyze table.
tk.MustExec("analyze table t")
// FIXME: We should correct the job info or skip this kind of job.
Copy link
Member Author

Choose a reason for hiding this comment

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

I will fix this problem in my next PR.

"Note 1105 Analyze use auto adjusted sample rate 1.000000 for table test.t, reason to use this rate is \"use min(1, 110000/10000) as the sample-rate=1\"",
),
)
// TODO: we should also include indexes in the job info.
Copy link
Member Author

Choose a reason for hiding this comment

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

I will improve it in my next PR.

…yze job

Signed-off-by: hi-rustin <rustin.liu@gmail.com>

fix

Signed-off-by: hi-rustin <rustin.liu@gmail.com>
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
@Rustin170506 Rustin170506 force-pushed the rustin-patch-sessionctx-stack1-analyze branch from e8f1d72 to d31c2d4 Compare June 27, 2024 07:53
Copy link
Member Author

@Rustin170506 Rustin170506 left a comment

Choose a reason for hiding this comment

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

🔢 Self-check (PR reviewed by myself and ready for feedback.)

Signed-off-by: hi-rustin <rustin.liu@gmail.com>
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
Copy link
Member Author

@Rustin170506 Rustin170506 left a comment

Choose a reason for hiding this comment

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

🔢 Self-check (PR reviewed by myself and ready for feedback.)

Signed-off-by: hi-rustin <rustin.liu@gmail.com>
@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jun 27, 2024
Copy link
Contributor

@AilinKid AilinKid left a comment

Choose a reason for hiding this comment

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

Rest LGTM

tk.MustExec("analyze table t")
// FIXME: We should correct the job info or skip this kind of job.
tk.MustQuery("select table_name, job_info from mysql.analyze_jobs order by id desc limit 1").Check(
testkit.Rows("t analyze table columns with 256 buckets, 100 topn, 1 samplerate"),
Copy link
Contributor

Choose a reason for hiding this comment

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

is that means all columns in L271's msg?

Copy link
Member Author

@Rustin170506 Rustin170506 Jun 28, 2024

Choose a reason for hiding this comment

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

This means we only analyzed the _row_id and updated the stats meta. I left a FIXME here, I will fix it in my next PR.

Co-authored-by: Arenatlx <ailinsilence4@gmail.com>
Copy link

ti-chi-bot bot commented Jun 28, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: AilinKid, qw4990

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

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jun 28, 2024
Copy link

ti-chi-bot bot commented Jun 28, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-06-27 09:42:25.474203643 +0000 UTC m=+885471.959692476: ☑️ agreed by qw4990.
  • 2024-06-28 09:04:25.952711678 +0000 UTC m=+969592.438200509: ☑️ agreed by AilinKid.

@Rustin170506
Copy link
Member Author

/retest

@ti-chi-bot ti-chi-bot bot merged commit 0d0fb4d into pingcap:master Jun 28, 2024
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm release-note-none Denotes a PR that doesn't merit a release note. sig/planner SIG: Planner size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants