pingcap / pingcap/tidb

a IN (1) OR a = 1 cannot be simplified

Open
#62,662 0 comments 0 reactions 1 assignee Claimed by @hawkingrei View on GitHub
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 test_table (
id INT PRIMARY KEY,
a INT
);
explain SELECT * FROM test_table WHERE a IN (1, 2, 3, 4) or a = 1;
```

### 2. What did you expect to see? (Required)

```
+---------------------+----------+-----------+------------------+-----------------------------------------------------------------+
| id | estRows | task | access object | operator info |
+---------------------+----------+-----------+------------------+-----------------------------------------------------------------+
| TableReader_8 | 40.00 | root | | data:Selection_7 |
| └─Selection_7 | 40.00 | cop[tikv] | | in(test.test_table.a, 1, 2, 3, 4) |
| └─TableFullScan_6 | 10000.00 | cop[tikv] | table:test_table | keep order:false, stats:pseudo |
+---------------------+----------+-----------+------------------+-----------------------------------------------------------------+
```

it should be ```in(test.test_table.a, 1, 2, 3, 4)```

### 3. What did you see instead (Required)

```
+---------------------+----------+-----------+------------------+-----------------------------------------------------------------+
| id | estRows | task | access object | operator info |
+---------------------+----------+-----------+------------------+-----------------------------------------------------------------+
| TableReader_8 | 40.00 | root | | data:Selection_7 |
| └─Selection_7 | 40.00 | cop[tikv] | | or(in(test.test_table.a, 1, 2, 3, 4), eq(test.test_table.a, 1)) |
| └─TableFullScan_6 | 10000.00 | cop[tikv] | table:test_table | keep order:false, stats:pseudo |
+---------------------+----------+-----------+------------------+-----------------------------------------------------------------+
```

but we get ```or(in(test.test_table.a, 1, 2, 3, 4), eq(test.test_table.a, 1))```
### 4. What is your TiDB version? (Required)

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.