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

derive index filters for mv index paths #54876

Closed
time-and-fate opened this issue Jul 24, 2024 · 0 comments · Fixed by #54877
Closed

derive index filters for mv index paths #54876

time-and-fate opened this issue Jul 24, 2024 · 0 comments · Fixed by #54877
Assignees
Labels
affects-8.1 sig/planner SIG: Planner type/enhancement The issue or PR belongs to an enhancement.

Comments

@time-and-fate
Copy link
Member

Enhancement

Currently, there will be no index filters for mv index paths. All filters will be put on the TableRowIDScan.

create table t (a int, b varchar(30), c float, j json, pk int primary key,key mvi1(c, (cast(j->'$.a' as unsigned array)), b),key mvi2(a, (cast(j->'$.c' as unsigned array))),key mvi3((cast(j->'$.d' as unsigned array)), c),key idx(b, c));

EXPLAIN format = brief SELECT /*+ use_index_merge(t, mvi1) */ * from t where c = 1 and json_overlaps(j->'$.a', '[4,5,6]') and b not like '%test%';
> EXPLAIN format = brief SELECT /*+ use_index_merge(t, mvi1) */ * from t where
    -> c = 1 and
    -> json_overlaps(j->'$.a', '[4,5,6]') and
    -> b not like '%test%';
+-------------------------------+---------+-----------+----------------------------------------------------------------------------------+----------------------------------------------------------------------------+
| id                            | estRows | task      | access object                                                                    | operator info                                                              |
+-------------------------------+---------+-----------+----------------------------------------------------------------------------------+----------------------------------------------------------------------------+
| Selection                     | 0.24    | root      |                                                                                  | json_overlaps(json_extract(test.t.j, "$.a"), cast("[4,5,6]", json BINARY)) |
| └─IndexMerge                  | 0.30    | root      |                                                                                  | type: union                                                                |
|   ├─IndexRangeScan(Build)     | 0.10    | cop[tikv] | table:t, index:mvi1(c, cast(json_extract(`j`, _utf8'$.a') as unsigned array), b) | range:[1 4,1 4], keep order:false, stats:pseudo                            |
|   ├─IndexRangeScan(Build)     | 0.10    | cop[tikv] | table:t, index:mvi1(c, cast(json_extract(`j`, _utf8'$.a') as unsigned array), b) | range:[1 5,1 5], keep order:false, stats:pseudo                            |
|   ├─IndexRangeScan(Build)     | 0.10    | cop[tikv] | table:t, index:mvi1(c, cast(json_extract(`j`, _utf8'$.a') as unsigned array), b) | range:[1 6,1 6], keep order:false, stats:pseudo                            |
|   └─Selection(Probe)          | 0.30    | cop[tikv] |                                                                                  | not(like(test.t.b, "%test%", 92))                                          |
|     └─TableRowIDScan          | 0.30    | cop[tikv] | table:t                                                                          | keep order:false, stats:pseudo                                             |
+-------------------------------+---------+-----------+----------------------------------------------------------------------------------+----------------------------------------------------------------------------+
7 rows in set, 1 warning (0.006 sec)


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

Successfully merging a pull request may close this issue.

1 participant