pingcap / pingcap/tidb

planner: incorrect est-row of IndexMerge upon MVIndex

Open
#40,348 3 comments 0 reactions 1 assignee Claimed by @qw4990 View on GitHub
epic/cardinality-estimation feature/developing severity/moderate sig/planner type/bug
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Bug Report

Please answer these questions before submitting your issue. Thanks!

### 1. Minimal reproduce step (Required)

```
create table t(a int, j json, index i_int((cast(j->'$.int' as signed array))));

select * from t where json_overlaps((j->'$.int'), '[1, 2, 3]');

"Selection 8000.00 root json_overlaps(json_extract(test.t.j, \"$.int\"), cast(\"[1, 2, 3]\", json BINARY))",
"└─IndexMerge 10.00 root type: union",
" ├─IndexRangeScan(Build) 10.00 cop[tikv] table:t, index:i_int(cast(json_extract(`j`, _utf8mb4'$.int') as signed array)) range:[1,1], keep order:false, stats:pseudo",
" ├─IndexRangeScan(Build) 10.00 cop[tikv] table:t, index:i_int(cast(json_extract(`j`, _utf8mb4'$.int') as signed array)) range:[2,2], keep order:false, stats:pseudo",
" ├─IndexRangeScan(Build) 10.00 cop[tikv] table:t, index:i_int(cast(json_extract(`j`, _utf8mb4'$.int') as signed array)) range:[3,3], keep order:false, stats:pseudo",
" └─TableRowIDScan(Probe) 10.00 cop[tikv] table:t keep order:false, stats:pseudo"
```

### 2. What did you expect to see? (Required)
The est-row of Selection shouldn't be larger than its child IndexMerge's `10.00`.

### 3. What did you see instead (Required)
`8000 > 10`

### 4. What is your TiDB version? (Required)

```
Release Version: v6.6.0-alpha-150-g09a7bce24d-dirty
Edition: Community
Git Commit Hash: 09a7bce24d7ffe888f09f1c562d60f2a5f181827
Git Branch: mvindex-estimation
UTC Build Time: 2023-01-05 11:09:17
GoVersion: go1.19.1
Race Enabled: false
TiKV Min Version: 6.2.0-alpha
Check Table Before Drop: false
Store: unistore |
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.