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: support Hypo indexes #43607

Merged
merged 5 commits into from May 16, 2023
Merged

planner: support Hypo indexes #43607

merged 5 commits into from May 16, 2023

Conversation

qw4990
Copy link
Contributor

@qw4990 qw4990 commented May 8, 2023

What problem does this PR solve?

Issue Number: close #43817

Problem Summary: support Hypo indexes

What is changed and how it works?

  1. Support to use create index {name} type hypo on {table} (c1, c2) to create hypo-indexes;
  2. Support to use drop index to remove hypo-indexes;
  3. Show create table can show all hypo-indexes;

Usage:

mysql> create table t (a int);
Query OK, 0 rows affected (0.03 sec)

mysql> explain select a from t where a = 1; -- no hypo-index
+-------------------------+----------+-----------+---------------+--------------------------------+
| id                      | estRows  | task      | access object | operator info                  |
+-------------------------+----------+-----------+---------------+--------------------------------+
| TableReader_7           | 10.00    | root      |               | data:Selection_6               |
| └─Selection_6           | 10.00    | cop[tikv] |               | eq(test.t.a, 1)                |
|   └─TableFullScan_5     | 10000.00 | cop[tikv] | table:t       | keep order:false, stats:pseudo |
+-------------------------+----------+-----------+---------------+--------------------------------+
3 rows in set (0.00 sec)

mysql> create index hypo_a type hypo on t (a);
Query OK, 0 rows affected (0.01 sec)

mysql> show create table t;
+-------+--------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                                     |
+-------+--------------------------------------------------------------------------------------------------------------------------------------------------+
| t     | CREATE TABLE `t` (
  `a` int(11) DEFAULT NULL,
  KEY `hypo_a` (`a`) /* HYPO INDEX */
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin |
+-------+--------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.01 sec)

mysql> explain select a from t where a = 1;
+------------------------+---------+-----------+--------------------------+---------------------------------------------+
| id                     | estRows | task      | access object            | operator info                               |
+------------------------+---------+-----------+--------------------------+---------------------------------------------+
| IndexReader_6          | 10.00   | root      |                          | index:IndexRangeScan_5                      |
| └─IndexRangeScan_5     | 10.00   | cop[tikv] | table:t, index:hypo_a(a) | range:[1,1], keep order:false, stats:pseudo |
+------------------------+---------+-----------+--------------------------+---------------------------------------------+
2 rows in set (0.00 sec)

mysql> drop index hypo_a on t;
Query OK, 0 rows affected (0.01 sec);

Check List

Tests

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

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
Copy link

ti-chi-bot bot commented May 8, 2023

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • chrysan
  • hawkingrei

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 ti-chi-bot bot added do-not-merge/invalid-title do-not-merge/needs-linked-issue release-note-none do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels May 8, 2023
@qw4990 qw4990 requested a review from a team as a code owner May 8, 2023 10:51
@ti-chi-bot ti-chi-bot bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels May 8, 2023
@qw4990 qw4990 changed the title [wip] Hypo index [wip] planner: Hypo index support May 8, 2023
@qw4990 qw4990 changed the title [wip] planner: Hypo index support planner: support Hypo indexes May 15, 2023
@ti-chi-bot ti-chi-bot bot removed do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. do-not-merge/needs-linked-issue labels May 15, 2023
@ti-chi-bot ti-chi-bot bot added the status/LGT1 Indicates that a PR has LGTM 1. label May 15, 2023
@qw4990 qw4990 added the sig/planner SIG: Planner label May 16, 2023
@ti-chi-bot ti-chi-bot bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels May 16, 2023
@qw4990
Copy link
Contributor Author

qw4990 commented May 16, 2023

/merge

@ti-chi-bot
Copy link

ti-chi-bot bot commented May 16, 2023

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

Commit hash: a7ed181

@ti-chi-bot ti-chi-bot bot added the status/can-merge Indicates a PR has been approved by a committer. label May 16, 2023
Copy link
Member

@bb7133 bb7133 left a comment

Choose a reason for hiding this comment

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

LGTM

@bb7133
Copy link
Member

bb7133 commented May 16, 2023

/merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note-none sig/planner SIG: Planner size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

planner: support hypo-indexes
4 participants