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

Support IndexMerge with UnionScan #28494

Closed
ichn-hu opened this issue Sep 30, 2021 · 3 comments
Closed

Support IndexMerge with UnionScan #28494

ichn-hu opened this issue Sep 30, 2021 · 3 comments
Labels
sig/planner SIG: Planner sig/transaction SIG:Transaction type/enhancement The issue or PR belongs to an enhancement.

Comments

@ichn-hu
Copy link
Contributor

ichn-hu commented Sep 30, 2021

Enhancement

currently TiDB's IndexMerge has a restriction that if it is in a transaction that has data changed before, it can not be applied, because we haven't yet supported index merge with union scan,

// TODO: implement UnionScan + IndexMerge

This fixes the todo here.

@ichn-hu ichn-hu added the type/enhancement The issue or PR belongs to an enhancement. label Sep 30, 2021
@ichn-hu
Copy link
Contributor Author

ichn-hu commented Sep 30, 2021

for some context, see pingcap/docs-cn#7237

@Defined2014
Copy link
Contributor

I think it already supportted in v7.1, so close it.

mysql> explain select * from t use index(idx, idx1) where a = 1 or b = 2;
+------------------------------------+---------+-----------+---------------------------+--------------------------------------------------------------------------------+
| id                                 | estRows | task      | access object             | operator info                                                                  |
+------------------------------------+---------+-----------+---------------------------+--------------------------------------------------------------------------------+
| Projection_5                       | 0.00    | root      |                           | test.t.a, test.t.b, test.t.c                                                   |
| └─UnionScan_6                      | 1.00    | root      |                           | or(eq(test.t.a, 1), eq(test.t.b, 2))                                           |
|   └─IndexMerge_18                  | 1.00    | root      |                           | type: union                                                                    |
|     ├─IndexRangeScan_15(Build)     | 1.00    | cop[tikv] | table:t, index:idx(a, c)  | range:[1,1], keep order:false, stats:partial[a:unInitialized, b:unInitialized] |
|     ├─IndexRangeScan_16(Build)     | 1.00    | cop[tikv] | table:t, index:idx1(b, c) | range:[2,2], keep order:false, stats:partial[a:unInitialized, b:unInitialized] |
|     └─TableRowIDScan_17(Probe)     | 1.00    | cop[tikv] | table:t                   | keep order:false, stats:partial[a:unInitialized, b:unInitialized]              |
+------------------------------------+---------+-----------+---------------------------+--------------------------------------------------------------------------------+
6 rows in set (0.00 sec)

@Defined2014
Copy link
Contributor

related PR #29875

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/planner SIG: Planner sig/transaction SIG:Transaction type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
Development

No branches or pull requests

2 participants