pingcap / pingcap/tidb

TiDB would not use the agg func to prune the unnecessary partitions

Open
#36,536 4 comments 0 reactions 1 assignee Claimed by @tiancaiamao View on GitHub
component/tablepartition sig/planner type/enhancement
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 (x int) partition by range (x) (
partition p0 values less than (5),
partition p1 values less than (10),
partition p2 values less than (15)
);
explain select max(x) from t;

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

```
+--------------------------------+----------+-----------+---------------+----------------------------------+
| id | estRows | task | access object | operator info |
+--------------------------------+----------+-----------+---------------+----------------------------------+
| StreamAgg_10 | 1.00 | root | | funcs:max(test.t.x)->Column#3 |
| └─TopN_11 | 1.00 | root | | test.t.x:desc, offset:0, count:1 |
| └─TableReader_19 | 1.00 | root | | data:TopN_18 |
| └─TopN_18 | 1.00 | cop[tikv] | | test.t.x:desc, offset:0, count:1 |
| └─Selection_17 | 999.00 | cop[tikv] | | not(isnull(test.t.x)) |
| └─TableFullScan_16 | 1000.00 | cop[tikv] | table:t partition:p2 | keep order:false, stats:pseudo |
+--------------------------------+----------+-----------+---------------+----------------------------------+
6 rows in set (0.00 sec)
```

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

```
+--------------------------------+----------+-----------+---------------+----------------------------------+
| id | estRows | task | access object | operator info |
+--------------------------------+----------+-----------+---------------+----------------------------------+
| StreamAgg_10 | 1.00 | root | | funcs:max(test.t.x)->Column#3 |
| └─TopN_11 | 1.00 | root | | test.t.x:desc, offset:0, count:1 |
| └─TableReader_19 | 1.00 | root | partition:all | data:TopN_18 |
| └─TopN_18 | 1.00 | cop[tikv] | | test.t.x:desc, offset:0, count:1 |
| └─Selection_17 | 9990.00 | cop[tikv] | | not(isnull(test.t.x)) |
| └─TableFullScan_16 | 10000.00 | cop[tikv] | table:t | keep order:false, stats:pseudo |
+--------------------------------+----------+-----------+---------------+----------------------------------+
6 rows in set (0.00 sec)
```

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

master

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.