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: include both indexes and columns in job info #54336

Merged
merged 14 commits into from
Jul 3, 2024

Conversation

Rustin170506
Copy link
Member

@Rustin170506 Rustin170506 commented Jul 1, 2024

What problem does this PR solve?

Issue Number: ref #53567

Problem Summary:

We display job_info in the mysql.analyze_jobs table. But we didn't include the indexes information in this column. We need to make it clearer after introducing the predicate columns feature because, by default, we only analyze the index if there are no predicate columns.

What changed and how does it work?

  • Removed the unused parameter and added more comments
  • Distinguished between singular and plural.
  • Included the indexes info.

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.

在 analyze_job 中显示分析了的 indexes 信息
Display information about analyzed indexes in analyze_job

@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jul 1, 2024
@Rustin170506 Rustin170506 changed the title planner: remove unused parameter and add more comments WIP: planner: remove unused parameter and add more comments Jul 1, 2024
@ti-chi-bot ti-chi-bot bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jul 1, 2024
Copy link

codecov bot commented Jul 1, 2024

Codecov Report

Attention: Patch coverage is 89.09091% with 6 lines in your changes missing coverage. Please review.

Project coverage is 56.2625%. Comparing base (230bbc2) to head (30d818b).
Report is 4 commits behind head on master.

Additional details and impacted files
@@                Coverage Diff                @@
##             master     #54336         +/-   ##
=================================================
- Coverage   72.8839%   56.2625%   -16.6214%     
=================================================
  Files          1533       1654        +121     
  Lines        436132     611098     +174966     
=================================================
+ Hits         317870     343819      +25949     
- Misses        98667     243782     +145115     
- Partials      19595      23497       +3902     
Flag Coverage Δ
integration 37.5935% <89.0909%> (?)

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

Components Coverage Δ
dumpling 52.9656% <ø> (ø)
parser ∅ <ø> (∅)
br 52.7512% <ø> (+6.6214%) ⬆️

@ti-chi-bot ti-chi-bot bot added the sig/planner SIG: Planner label Jul 1, 2024
@ti-chi-bot ti-chi-bot bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 1, 2024
@Rustin170506 Rustin170506 changed the title WIP: planner: remove unused parameter and add more comments planner: remove unused parameter and add more comments Jul 1, 2024
@ti-chi-bot ti-chi-bot bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note-none Denotes a PR that doesn't merit a release note. labels Jul 1, 2024
@Rustin170506 Rustin170506 changed the title planner: remove unused parameter and add more comments planner: include both indexes and columns in job info Jul 1, 2024
@Rustin170506
Copy link
Member Author

Tested locally:

  1. Start the TiDB cluster with patch: tiup playground nightly --db.binpath /Volumes/t7/code/tidb/bin/tidb-server
  2. Create a table:
mysql> create table t (a int, b int, c int);
Query OK, 0 rows affected (0.08 sec)
  1. Enable the feature:
mysql> set global tidb_analyze_column_options='PREDICATE';
Query OK, 0 rows affected (0.01 sec)
  1. Insert some data:
mysql> insert into t values (1, 1, 1), (2, 2, 2), (3, 3, 3);
Query OK, 3 rows affected (0.01 sec)
Records: 3  Duplicates: 0  Warnings: 0
  1. Check the stats meta:
mysql> select * from mysql.stats_meta;
+--------------------+----------+--------------+-------+----------+
| version            | table_id | modify_count | count | snapshot |
+--------------------+----------+--------------+-------+----------+
| 450840965863178242 |      104 |            3 |     3 |        0 |
+--------------------+----------+--------------+-------+----------+
1 row in set (0.00 sec)
  1. Analyze the table:
mysql> analyze table t;
Query OK, 0 rows affected, 2 warnings (0.05 sec)
  1. Check the analyze job(no indexes and no columns):
mysql> select table_name, job_info from mysql.analyze_jobs;
+------------+--------------------------------------------------------+
| table_name | job_info                                               |
+------------+--------------------------------------------------------+
| t          | analyze table with 256 buckets, 100 topn, 1 samplerate |
+------------+--------------------------------------------------------+
1 row in set (0.00 sec)
  1. Check the stats_meta:
mysql> select * from mysql.stats_meta;
+--------------------+----------+--------------+-------+--------------------+
| version            | table_id | modify_count | count | snapshot           |
+--------------------+----------+--------------+-------+--------------------+
| 450840975760424971 |      104 |            0 |     3 | 450840975747317761 |
+--------------------+----------+--------------+-------+--------------------+
1 row in set (0.00 sec)

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.)

@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jul 1, 2024
@Rustin170506
Copy link
Member Author

/retest

@@ -175,7 +175,7 @@ func TestAnalyzeTableWithTiDBPersistAnalyzeOptionsDisabled(t *testing.T) {
// Analyze again, it should use the predicate columns.
tk.MustExec("analyze table t")
tk.MustQuery("select table_name, job_info from mysql.analyze_jobs order by id desc limit 1").Check(
testkit.Rows("t analyze table columns a with 256 buckets, 100 topn, 1 samplerate"),
testkit.Rows("t analyze table column a 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.

Why not columns in here ? It seems that t table has two columns

Copy link
Member Author

Choose a reason for hiding this comment

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

Because we only analyze predicate columns here. We only used column a above.

Copy link
Contributor

@elsa0520 elsa0520 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

ti-chi-bot bot commented Jul 2, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: elsa0520, hawkingrei

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 Jul 2, 2024
Copy link

ti-chi-bot bot commented Jul 2, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-07-01 09:44:09.098272849 +0000 UTC m=+1231175.583761681: ☑️ agreed by hawkingrei.
  • 2024-07-02 07:38:54.83133113 +0000 UTC m=+1310061.316819962: ☑️ agreed by elsa0520.

@Rustin170506
Copy link
Member Author

/retest

3 similar comments
@hawkingrei
Copy link
Member

/retest

@qw4990
Copy link
Contributor

qw4990 commented Jul 2, 2024

/retest

@Rustin170506
Copy link
Member Author

/retest

@hawkingrei
Copy link
Member

/test all

@hawkingrei
Copy link
Member

TestAnalyzeMVIndex failed.

@Rustin170506
Copy link
Member Author

/retest

3 similar comments
@Rustin170506
Copy link
Member Author

/retest

@Rustin170506
Copy link
Member Author

/retest

@Rustin170506
Copy link
Member Author

/retest

@ti-chi-bot ti-chi-bot bot merged commit aeea03d into pingcap:master Jul 3, 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 Denotes a PR that will be considered when it comes time to generate release notes. sig/planner SIG: Planner size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants