CREATE TABLE part_exec
(
a int,
b int,
c int,
d int
)WITH(orientation=row)
PARTITION BY RANGE (a, b)
(
PARTITION P_050_BEFORE VALUES LESS THAN (100, 100),
PARTITION P_100 VALUES LESS THAN (100, 200),
PARTITION P_150 VALUES LESS THAN (200, 100),
PARTITION P_200 VALUES LESS THAN (200, 200)
);
COPY part_exec FROM '@abs_srcdir@/data/partition_pathkey.dat';
analyze part_exec;
set plan_mode_seed = -1;
-- case 1
create index idx_part_exe_a on part_exec(a) local;
select * from part_exec order by a limit 10; -- OK
select * from part_exec order by a desc limit 10; -- OK
select * from part_exec where b = 10 order by a, b limit 10; -- OK
select * from part_exec where b = 10 order by a desc, b desc limit 10; -- OK
select * from part_exec order by a asc nulls first limit 10;
select * from part_exec order by a desc nulls last limit 10;
select * from part_exec order by b,c limit 10;
-- case 2
drop index idx_part_exe_a;
create index idx_part_exe_a_b on part_exec(a,b) local;
select * from part_exec order by a limit 10; -- OK
select * from part_exec order by a desc limit 10; -- OK
select * from part_exec order by a, b limit 10; -- OK
select * from part_exec order by a desc, b desc limit 10; -- OK
select * from part_exec where c = 10 order by a, b, c limit 10; -- OK
select * from part_exec where c = 10 order by a desc, b desc, c desc limit 10; -- OK
select * from part_exec order by a asc, b desc limit 10;
select * from part_exec order by a desc, b asc limit 10;
select * from part_exec order by a desc, b desc nulls last limit 10;
select * from part_exec order by a desc nulls last, b desc limit 10;
select * from part_exec order by a desc nulls last limit 10;
select * from part_exec order by a asc nulls first limit 10;
select * from part_exec order by b,c limit 10;
select * from part_exec order by a, b, c limit 10;
drop index idx_part_exe_a_b;
create index idx_part_exe_a_b_c on part_exec(a,b,c) local;
select * from part_exec order by a limit 10; -- OK
select * from part_exec order by a desc limit 10; -- OK
select * from part_exec order by a, b limit 10; -- OK
select * from part_exec order by a desc, b desc limit 10; -- OK
select * from part_exec order by a, b, c limit 10; -- OK
select * from part_exec order by a desc, b desc, c desc limit 10; -- OK
select * from part_exec where a = 50 order by b, c limit 10; -- OK
select * from part_exec where a < 100 order by a, b, c limit 10; -- OK
select * from part_exec where a = 10 and b = 10 order by a, b, c limit 10; -- OK
select * from part_exec order by b, c limit 10;
drop index idx_part_exe_a_b_c;
create index idx_part_exe_a_b_c on part_exec(a desc,b,c desc) local;
select * from part_exec where a < 100 order by a desc, b, c desc limit 10; -- OK
select * from part_exec where a < 100 and b < 100 order by a desc, b, c desc limit 10; -- OK
select * from part_exec where a < 100 and b < 100 order by a , b desc, c limit 10; -- OK
select * from part_exec where b = 10 order by a desc, c desc limit 10; -- OK
drop index idx_part_exe_a_b_c;
create index idx_part_exe_b_c on part_exec(b,c) local;
select * from part_exec where a = 80 order by b,c limit 10; -- OK
select * from part_exec where a < 80 order by b,c limit 10; -- OK
select * from part_exec where a = 80 order by b desc,c desc limit 10; -- OK
select * from part_exec where a = 80 and b = 80 order by c limit 10; -- OK
select * from part_exec where a = 80 and c = 80 order by b limit 10; -- OK
select * from part_exec where a < 200 and a > 100 order by b,c limit 10; -- OK
select * from part_exec order by b,c limit 10;
drop index idx_part_exe_b_c;
create index idx_part_exe_a_d on part_exec(a,d) local;
select * from part_exec where b = 10 order by a, d limit 10; -- OK
select * from part_exec where b = 10 order by a desc, d desc limit 10; -- OK
select * from part_exec where a < 80 order by a, d limit 10; -- OK
DROP TABLE part_exec;