pingcap / pingcap/tidb

planner: window function does not apply fine grained shuffle

Open
#43,923 1 comment 0 reactions 0 assignees View on GitHub
component/tiflash may-affects-5.1 may-affects-5.2 may-affects-5.3 may-affects-5.4 may-affects-6.1 may-affects-6.5 may-affects-7.1 severity/moderate sig/execution 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.t1(c1 int, c2 int);
insert into test.t1 values(1, 1),(2, 2),(3, 3),(1, 1),(2, 2),(3, 3),(4, 4);
alter table test.t1 set tiflash replica 1;
set tidb_allow_mpp=1;set tidb_enforce_mpp=1; set tidb_isolation_read_engines='tiflash';
explain select c1, row_number() OVER(partition by c1) from (select c1 from test.t1 group by c1) t;
```

### 2. What did you expect to see? (Required)
window and sort should apply fine grained shuffle.

### 3. What did you see instead (Required)
```
+--------------------------------------+---------+--------------+---------------+------------------------------------------------------------------------------------------------------------------+
| id | estRows | task | access object | operator info |
+--------------------------------------+---------+--------------+---------------+------------------------------------------------------------------------------------------------------------------+
| TableReader_58 | 5.60 | root | | MppVersion: 1, data:ExchangeSender_57 |
| └─ExchangeSender_57 | 5.60 | mpp[tiflash] | | ExchangeType: PassThrough |
| └─Window_56 | 5.60 | mpp[tiflash] | | row_number()->Column#5 over(partition by test.t1.c1 rows between current row and current row) |
| └─Sort_18 | 5.60 | mpp[tiflash] | | test.t1.c1 |
| └─Projection_17 | 5.60 | mpp[tiflash] | | test.t1.c1 |
| └─HashAgg_12 | 5.60 | mpp[tiflash] | | group by:test.t1.c1, funcs:firstrow(test.t1.c1)->test.t1.c1, stream_count: 20 |
| └─ExchangeReceiver_16 | 7.00 | mpp[tiflash] | | stream_count: 20 |
| └─ExchangeSender_15 | 7.00 | mpp[tiflash] | | ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: test.t1.c1, collate: binary], stream_count: 20 |
| └─TableFullScan_14 | 7.00 | mpp[tiflash] | table:t1 | keep order:false, stats:pseudo |
+--------------------------------------+---------+--------------+---------------+------------------------------------------------------------------------------------------------------------------+
```

### 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.