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

small cached table doesn't support index merge #29682

Closed
Tracked by #25293
tiancaiamao opened this issue Nov 11, 2021 · 1 comment
Closed
Tracked by #25293

small cached table doesn't support index merge #29682

tiancaiamao opened this issue Nov 11, 2021 · 1 comment
Labels
type/enhancement The issue or PR belongs to an enhancement.

Comments

@tiancaiamao
Copy link
Contributor

Enhancement

While developing, I found this #29443 (comment), thanks to @lcwangchao for pointing it out.
and seaching the issues list, there is a known issue #28494 here

So small cached table doesn't support index merge

This limitation is imposed by the fact union scan doesn't support index merge...
small cached table implemetation depends on union scan, so it gets the same limitation.

@Defined2014
Copy link
Contributor

Defined2014 commented May 15, 2023

I think the IndexMerge works well with small cached table now. And IndexMerge already supported UnionScan by #29875, so close this issue.

mysql> explain select /*+ use_index_merge(tcommon, idx_ac, idx_bc) */ * from tcommon where a = 1 or b = 1;
+---------------------------------+---------+-----------+-----------------------------------+--------------------------------------------------------------------------------+
| id                              | estRows | task      | access object                     | operator info                                                                  |
+---------------------------------+---------+-----------+-----------------------------------+--------------------------------------------------------------------------------+
| UnionScan_6                     | 1.00    | root      |                                   | or(eq(test.tcommon.a, 1), eq(test.tcommon.b, 1))                               |
| └─IndexMerge_10                 | 1.00    | root      |                                   | type: union                                                                    |
|   ├─IndexRangeScan_7(Build)     | 1.00    | cop[tikv] | table:tcommon, index:idx_ac(a, c) | range:[1,1], keep order:false, stats:partial[a:unInitialized, b:unInitialized] |
|   ├─IndexRangeScan_8(Build)     | 1.00    | cop[tikv] | table:tcommon, index:idx_bc(b, c) | range:[1,1], keep order:false, stats:partial[a:unInitialized, b:unInitialized] |
|   └─TableRowIDScan_9(Probe)     | 1.00    | cop[tikv] | table:tcommon                     | keep order:false, stats:partial[a:unInitialized, b:unInitialized]              |
+---------------------------------+---------+-----------+-----------------------------------+--------------------------------------------------------------------------------+
5 rows in set (0.01 sec)

mysql> select /*+ use_index_merge(tcommon, idx_ac, idx_bc) */ * from tcommon where a = 1 or b = 1;
+---+------+---+---+
| a | b    | c | d |
+---+------+---+---+
| 1 |    2 | 3 | 1 |
+---+------+---+---+
1 row in set (0.00 sec)

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

No branches or pull requests

2 participants