Files
tidb/cmd/explaintest/r/window_function.result

127 lines
8.4 KiB
Plaintext

use test;
drop table if exists t;
create table t (a int, b int, c timestamp, index idx(a));
set @@tidb_enable_window_function = 1;
set @@session.tidb_window_concurrency = 1;
explain select sum(a) over() from t;
id count task operator info
Projection_7 10000.00 root Column#6
└─Window_8 10000.00 root sum(cast(test.t.a))->Column#6 over()
└─IndexReader_12 10000.00 root index:IndexScan_11
└─IndexScan_11 10000.00 cop[tikv] table:t, index:a, range:[NULL,+inf], keep order:false, stats:pseudo
explain select sum(a) over(partition by a) from t;
id count task operator info
Projection_7 10000.00 root Column#6
└─Window_8 10000.00 root sum(cast(test.t.a))->Column#6 over(partition by test.t.a)
└─IndexReader_10 10000.00 root index:IndexScan_9
└─IndexScan_9 10000.00 cop[tikv] table:t, index:a, range:[NULL,+inf], keep order:true, stats:pseudo
explain select sum(a) over(partition by a order by b) from t;
id count task operator info
Projection_7 10000.00 root Column#6
└─Window_8 10000.00 root sum(cast(test.t.a))->Column#6 over(partition by test.t.a order by test.t.b asc range between unbounded preceding and current row)
└─Sort_11 10000.00 root test.t.a:asc, test.t.b:asc
└─TableReader_10 10000.00 root data:TableScan_9
└─TableScan_9 10000.00 cop[tikv] table:t, range:[-inf,+inf], keep order:false, stats:pseudo
explain select sum(a) over(partition by a order by b rows unbounded preceding) from t;
id count task operator info
Projection_7 10000.00 root Column#6
└─Window_8 10000.00 root sum(cast(test.t.a))->Column#6 over(partition by test.t.a order by test.t.b asc rows between unbounded preceding and current row)
└─Sort_11 10000.00 root test.t.a:asc, test.t.b:asc
└─TableReader_10 10000.00 root data:TableScan_9
└─TableScan_9 10000.00 cop[tikv] table:t, range:[-inf,+inf], keep order:false, stats:pseudo
explain select sum(a) over(partition by a order by b rows between 1 preceding and 1 following) from t;
id count task operator info
Projection_7 10000.00 root Column#6
└─Window_8 10000.00 root sum(cast(test.t.a))->Column#6 over(partition by test.t.a order by test.t.b asc rows between 1 preceding and 1 following)
└─Sort_11 10000.00 root test.t.a:asc, test.t.b:asc
└─TableReader_10 10000.00 root data:TableScan_9
└─TableScan_9 10000.00 cop[tikv] table:t, range:[-inf,+inf], keep order:false, stats:pseudo
explain select sum(a) over(partition by a order by b range between 1 preceding and 1 following) from t;
id count task operator info
Projection_7 10000.00 root Column#6
└─Window_8 10000.00 root sum(cast(test.t.a))->Column#6 over(partition by test.t.a order by test.t.b asc range between 1 preceding and 1 following)
└─Sort_11 10000.00 root test.t.a:asc, test.t.b:asc
└─TableReader_10 10000.00 root data:TableScan_9
└─TableScan_9 10000.00 cop[tikv] table:t, range:[-inf,+inf], keep order:false, stats:pseudo
explain select sum(a) over(partition by a order by c range between interval '2:30' minute_second preceding and interval '2:30' minute_second following) from t;
id count task operator info
Projection_7 10000.00 root Column#6
└─Window_8 10000.00 root sum(cast(test.t.a))->Column#6 over(partition by test.t.a order by test.t.c asc range between interval "2:30" "MINUTE_SECOND" preceding and interval "2:30" "MINUTE_SECOND" following)
└─Sort_11 10000.00 root test.t.a:asc, test.t.c:asc
└─TableReader_10 10000.00 root data:TableScan_9
└─TableScan_9 10000.00 cop[tikv] table:t, range:[-inf,+inf], keep order:false, stats:pseudo
set @@session.tidb_window_concurrency = 4;
explain select sum(a) over() from t;
id count task operator info
Projection_7 10000.00 root Column#6
└─Window_8 10000.00 root sum(cast(test.t.a))->Column#6 over()
└─IndexReader_12 10000.00 root index:IndexScan_11
└─IndexScan_11 10000.00 cop[tikv] table:t, index:a, range:[NULL,+inf], keep order:false, stats:pseudo
explain select sum(a) over(partition by a) from t;
id count task operator info
Projection_7 10000.00 root Column#6
└─Window_8 10000.00 root sum(cast(test.t.a))->Column#6 over(partition by test.t.a)
└─IndexReader_10 10000.00 root index:IndexScan_9
└─IndexScan_9 10000.00 cop[tikv] table:t, index:a, range:[NULL,+inf], keep order:true, stats:pseudo
explain select sum(a) over(partition by a order by b) from t;
id count task operator info
Projection_7 10000.00 root Column#6
└─Shuffle_12 10000.00 root execution info: concurrency:4, data source:TableReader_10
└─Window_8 10000.00 root sum(cast(test.t.a))->Column#6 over(partition by test.t.a order by test.t.b asc range between unbounded preceding and current row)
└─Sort_11 10000.00 root test.t.a:asc, test.t.b:asc
└─TableReader_10 10000.00 root data:TableScan_9
└─TableScan_9 10000.00 cop[tikv] table:t, range:[-inf,+inf], keep order:false, stats:pseudo
explain select sum(a) over(partition by a order by b rows unbounded preceding) from t;
id count task operator info
Projection_7 10000.00 root Column#6
└─Shuffle_12 10000.00 root execution info: concurrency:4, data source:TableReader_10
└─Window_8 10000.00 root sum(cast(test.t.a))->Column#6 over(partition by test.t.a order by test.t.b asc rows between unbounded preceding and current row)
└─Sort_11 10000.00 root test.t.a:asc, test.t.b:asc
└─TableReader_10 10000.00 root data:TableScan_9
└─TableScan_9 10000.00 cop[tikv] table:t, range:[-inf,+inf], keep order:false, stats:pseudo
explain select sum(a) over(partition by a order by b rows between 1 preceding and 1 following) from t;
id count task operator info
Projection_7 10000.00 root Column#6
└─Shuffle_12 10000.00 root execution info: concurrency:4, data source:TableReader_10
└─Window_8 10000.00 root sum(cast(test.t.a))->Column#6 over(partition by test.t.a order by test.t.b asc rows between 1 preceding and 1 following)
└─Sort_11 10000.00 root test.t.a:asc, test.t.b:asc
└─TableReader_10 10000.00 root data:TableScan_9
└─TableScan_9 10000.00 cop[tikv] table:t, range:[-inf,+inf], keep order:false, stats:pseudo
explain select sum(a) over(partition by a order by b range between 1 preceding and 1 following) from t;
id count task operator info
Projection_7 10000.00 root Column#6
└─Shuffle_12 10000.00 root execution info: concurrency:4, data source:TableReader_10
└─Window_8 10000.00 root sum(cast(test.t.a))->Column#6 over(partition by test.t.a order by test.t.b asc range between 1 preceding and 1 following)
└─Sort_11 10000.00 root test.t.a:asc, test.t.b:asc
└─TableReader_10 10000.00 root data:TableScan_9
└─TableScan_9 10000.00 cop[tikv] table:t, range:[-inf,+inf], keep order:false, stats:pseudo
explain select sum(a) over(partition by a order by c range between interval '2:30' minute_second preceding and interval '2:30' minute_second following) from t;
id count task operator info
Projection_7 10000.00 root Column#6
└─Shuffle_12 10000.00 root execution info: concurrency:4, data source:TableReader_10
└─Window_8 10000.00 root sum(cast(test.t.a))->Column#6 over(partition by test.t.a order by test.t.c asc range between interval "2:30" "MINUTE_SECOND" preceding and interval "2:30" "MINUTE_SECOND" following)
└─Sort_11 10000.00 root test.t.a:asc, test.t.c:asc
└─TableReader_10 10000.00 root data:TableScan_9
└─TableScan_9 10000.00 cop[tikv] table:t, range:[-inf,+inf], keep order:false, stats:pseudo
drop table if exists t1;
create table t1(a int primary key, b int);
insert into t1 values(1, 1), (2, 1);
analyze table t1;
explain select sum(a) over(partition by b) from t1;
id count task operator info
Projection_7 2.00 root Column#4
└─Window_8 2.00 root sum(cast(test.t1.a))->Column#4 over(partition by test.t1.b)
└─Sort_11 2.00 root test.t1.b:asc
└─TableReader_10 2.00 root data:TableScan_9
└─TableScan_9 2.00 cop[tikv] table:t1, range:[-inf,+inf], keep order:false
insert into t1 values(3, 3);
analyze table t1;
explain select sum(a) over(partition by b) from t1;
id count task operator info
Projection_7 3.00 root Column#4
└─Shuffle_12 3.00 root execution info: concurrency:2, data source:TableReader_10
└─Window_8 3.00 root sum(cast(test.t1.a))->Column#4 over(partition by test.t1.b)
└─Sort_11 3.00 root test.t1.b:asc
└─TableReader_10 3.00 root data:TableScan_9
└─TableScan_9 3.00 cop[tikv] table:t1, range:[-inf,+inf], keep order:false