You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

31 lines
1.7 KiB

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;
explain select sum(a) over(partition by a) from t;
explain select sum(a) over(partition by a order by b) from t;
explain select sum(a) over(partition by a order by b rows unbounded preceding) from t;
explain select sum(a) over(partition by a order by b rows between 1 preceding and 1 following) from t;
explain select sum(a) over(partition by a order by b range between 1 preceding and 1 following) from t;
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;
set @@session.tidb_window_concurrency = 4;
explain select sum(a) over() from t;
explain select sum(a) over(partition by a) from t;
explain select sum(a) over(partition by a order by b) from t;
explain select sum(a) over(partition by a order by b rows unbounded preceding) from t;
explain select sum(a) over(partition by a order by b rows between 1 preceding and 1 following) from t;
explain select sum(a) over(partition by a order by b range between 1 preceding and 1 following) from t;
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;
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;
insert into t1 values(3, 3);
analyze table t1;
explain select sum(a) over(partition by b) from t1;