248 lines
16 KiB
Plaintext
248 lines
16 KiB
Plaintext
drop table if exists t1,t2,t3,t4,t8;
|
|
create table t1(c1 int primary key, c2 int);
|
|
create table t2(c1 int primary key, c2 int);
|
|
create table t3(c1 int, c2 int primary key);
|
|
create table t4(c1 int primary key, c2 int);
|
|
insert into t1 values(1,1),(2,2),(3,3),(4,4),(5,5);
|
|
insert into t2 values(0,0),(2,2),(4,4),(6,6);
|
|
insert into t3 values(1,1),(3,3),(5,5),(7,7);
|
|
insert into t4 values(1,0),(2,0),(3,1),(4,1);
|
|
(select * from t1 where false ) intersect (select * from t2 where false);
|
|
c1 c2
|
|
(select * from t1 where false ) intersect all (select * from t2 where false);
|
|
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your OceanBase version for the right syntax to use near 'all (select * from t2 where false)' at line 1
|
|
(select * from t1 where false ) intersect select * from t2;
|
|
c1 c2
|
|
(select * from t1 where false ) intersect all select * from t2;
|
|
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your OceanBase version for the right syntax to use near 'all select * from t2' at line 1
|
|
select * from t1 intersect (select * from t2 where false);
|
|
c1 c2
|
|
select * from t1 intersect all (select * from t2 where false);
|
|
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your OceanBase version for the right syntax to use near 'all (select * from t2 where false)' at line 1
|
|
(select * from t1 where false) intersect (select * from t2 where false) intersect (select * from t3 where false);
|
|
c1 c2
|
|
(select * from t1 where false) intersect all (select * from t2 where false) intersect (select * from t3 where false);
|
|
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your OceanBase version for the right syntax to use near 'all (select * from t2 where false) intersect (select * from t3 where false)' at line 1
|
|
select c1 from t1 intersect select c1 from t1;
|
|
c1
|
|
1
|
|
2
|
|
3
|
|
4
|
|
5
|
|
select c1 from t1 intersect all select c1 from t1;
|
|
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your OceanBase version for the right syntax to use near 'all select c1 from t1' at line 1
|
|
select c1 from t1 intersect select c1 from t4;
|
|
c1
|
|
1
|
|
2
|
|
3
|
|
4
|
|
select c1 from t1 intersect all select c1 from t4;
|
|
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your OceanBase version for the right syntax to use near 'all select c1 from t4' at line 1
|
|
select c1 from t4 intersect select c1 from t1;
|
|
c1
|
|
1
|
|
2
|
|
3
|
|
4
|
|
select c1 from t4 intersect all select c1 from t1;
|
|
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your OceanBase version for the right syntax to use near 'all select c1 from t1' at line 1
|
|
select c1 from t2 intersect select c1 from t3;
|
|
c1
|
|
select c1 from t2 intersect all select c1 from t3;
|
|
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your OceanBase version for the right syntax to use near 'all select c1 from t3' at line 1
|
|
select c1 from t1 intersect select c1 from t2;
|
|
c1
|
|
2
|
|
4
|
|
select c1 from t1 intersect all select c1 from t2;
|
|
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your OceanBase version for the right syntax to use near 'all select c1 from t2' at line 1
|
|
select c2 from t4 intersect select c2 from t1;
|
|
c2
|
|
1
|
|
select c2 from t4 intersect all select c2 from t1;
|
|
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your OceanBase version for the right syntax to use near 'all select c2 from t1' at line 1
|
|
select c2 from t1 intersect select c2 from t4;
|
|
c2
|
|
1
|
|
select c2 from t1 intersect all select c2 from t4;
|
|
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your OceanBase version for the right syntax to use near 'all select c2 from t4' at line 1
|
|
select * from t1 intersect (select * from t2 union select * from t3) ;
|
|
c1 c2
|
|
1 1
|
|
2 2
|
|
3 3
|
|
4 4
|
|
5 5
|
|
select * from t1 intersect all (select * from t2 union select * from t3) ;
|
|
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your OceanBase version for the right syntax to use near 'all (select * from t2 union select * from t3)' at line 1
|
|
(select * from t1 intersect select * from t2) union (select * from t1 intersect select * from t3);
|
|
c1 c2
|
|
1 1
|
|
2 2
|
|
3 3
|
|
4 4
|
|
5 5
|
|
select * from t1 intersect all (select * from t2 union select * from t3) ;
|
|
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your OceanBase version for the right syntax to use near 'all (select * from t2 union select * from t3)' at line 1
|
|
select c2 from t1 intersect select c2 from t3 intersect select c2 from t4;
|
|
c2
|
|
1
|
|
select c2 from t1 intersect all select c2 from t3 intersect select c2 from t4;
|
|
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your OceanBase version for the right syntax to use near 'all select c2 from t3 intersect select c2 from t4' at line 1
|
|
select c2 from t1 intersect (select c2 from t3 intersect select c2 from t4);
|
|
c2
|
|
1
|
|
select c2 from t1 intersect all (select c2 from t3 intersect select c2 from t4);
|
|
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your OceanBase version for the right syntax to use near 'all (select c2 from t3 intersect select c2 from t4)' at line 1
|
|
drop table if exists t5,t6;
|
|
create table t5(c1 int primary key, c2 int);
|
|
create table t6(c1 int primary key, c2 int);
|
|
insert into t5 values(1,1),(2,2),(3,3),(4,4),(5,5),(6,2),(7,3),(8,6),(9,6),(10,4),(11,2);
|
|
insert into t6 values(0,0),(2,2),(4,4),(6,6),(1,2),(3,4),(5,6);
|
|
select c2 from t5 intersect select c2 from t6;
|
|
c2
|
|
2
|
|
4
|
|
6
|
|
select c2 from t5 intersect all select c2 from t6;
|
|
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your OceanBase version for the right syntax to use near 'all select c2 from t6' at line 1
|
|
select c2 from t5 intersect select c1,c2 from t6;
|
|
ERROR 21000: The used SELECT statements have a different number of columns
|
|
create table t8 (c1 BINARY(99) ,c2 INTEGER(127) ,c3 VARBINARY(71) ,c4 BINARY(65) ,c5 BIGINT(127) ,c6 INTEGER(127) ,c7 INT(127) ,c8 INTEGER(127) ,c9 NUMERIC(64,25) ,c10 VARBINARY(55) ,c11 BIGINT(127) ,c12 VARCHAR(86) ,c13 INTEGER(127) ,c14 INT(127) ,c15 INTEGER(127) ,c16 DECIMAL(64,15) ,c17 INTEGER(127) ,c18 VARBINARY(76) ,c19 INTEGER(127) , primary key(c7,c6), index i_OkcN(c19) global, index i_ahayugXY(c10,c18) global, index i_iA(c16,c2) global) DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_bin PARTITION BY KEY(c7) PARTITIONS 20;
|
|
insert into t8 values('cdxLVdvvJjcoHFBECqXKkRGoMXYgNsTpJRrqYaluQdfEeB00000',0,'RetSgyIigYXIPgBXBsmZHQZQPLWcGoELCf00000','wD00000',0,0,0,0,0.0000000000000000000000000,'ieLhJAFmNCq00000',0,'DcKPncNvJjyYcNJKFmVUVhqvgUlLfINbycifYNHjzqALoLfn00000',0,0,0,0.000000000000000,0,'MojimRsQZuotWXMuvSQVDSdCmOaloSXNLRTxMYYXaxGbtuk00000',0);
|
|
explain (select /*+USE_HASH_AGGREGATION*/ c15 from (select c15 from t8) except (select c15 from t8) order by 1 limit 1000) union all (select t8_alias1.c10 from t8 t8_alias1 limit 1);
|
|
Query Plan
|
|
================================================================================
|
|
|ID|OPERATOR |NAME |EST.ROWS|EST.TIME(us)|
|
|
--------------------------------------------------------------------------------
|
|
|0 |UNION ALL | |2 |88 |
|
|
|1 |├─TOP-N SORT | |1 |86 |
|
|
|2 |│ └─HASH EXCEPT DISTINCT | |1 |86 |
|
|
|3 |│ ├─PX COORDINATOR | |1 |43 |
|
|
|4 |│ │ └─EXCHANGE OUT DISTR |:EX10000 |1 |43 |
|
|
|5 |│ │ └─PX PARTITION ITERATOR| |1 |43 |
|
|
|6 |│ │ └─TABLE FULL SCAN |t8 |1 |43 |
|
|
|7 |│ └─PX COORDINATOR | |1 |43 |
|
|
|8 |│ └─EXCHANGE OUT DISTR |:EX20000 |1 |43 |
|
|
|9 |│ └─PX PARTITION ITERATOR| |1 |43 |
|
|
|10|│ └─TABLE FULL SCAN |t8 |1 |43 |
|
|
|11|└─DISTRIBUTED TABLE FULL SCAN |t8_alias1(i_ahayugXY)|1 |3 |
|
|
================================================================================
|
|
Outputs & filters:
|
|
-------------------------------------
|
|
0 - output([UNION([1])]), filter(nil), rowset=16
|
|
1 - output([cast(EXCEPT([1]), VARCHAR(127))]), filter(nil), rowset=16
|
|
sort_keys([EXCEPT([1]), ASC]), topn(1000)
|
|
2 - output([EXCEPT([1])], [cast(EXCEPT([1]), VARCHAR(127))]), filter(nil), rowset=16
|
|
3 - output([t8.c15]), filter(nil), rowset=16
|
|
4 - output([t8.c15]), filter(nil), rowset=16
|
|
dop=1
|
|
5 - output([t8.c15]), filter(nil), rowset=16
|
|
force partition granule
|
|
6 - output([t8.c15]), filter(nil), rowset=16
|
|
access([t8.c15]), partitions(p[0-19])
|
|
is_index_back=false, is_global_index=false,
|
|
range_key([t8.c7], [t8.c6]), range(MIN,MIN ; MAX,MAX)always true
|
|
7 - output([t8.c15]), filter(nil), rowset=16
|
|
8 - output([t8.c15]), filter(nil), rowset=16
|
|
dop=1
|
|
9 - output([t8.c15]), filter(nil), rowset=16
|
|
force partition granule
|
|
10 - output([t8.c15]), filter(nil), rowset=16
|
|
access([t8.c15]), partitions(p[0-19])
|
|
is_index_back=false, is_global_index=false,
|
|
range_key([t8.c7], [t8.c6]), range(MIN,MIN ; MAX,MAX)always true
|
|
11 - output([t8_alias1.c10]), filter(nil), rowset=16
|
|
access([t8_alias1.c10]), partitions(p0)
|
|
limit(1), offset(nil), is_index_back=false, is_global_index=true,
|
|
range_key([t8_alias1.c10], [t8_alias1.c18], [t8_alias1.c7], [t8_alias1.c6]), range(MIN,MIN,MIN,MIN ; MAX,MAX,MAX,MAX)always true
|
|
(select /*+USE_HASH_AGGREGATION*/ c15 from (select c15 from t8) except (select c15 from t8) order by 1 limit 1000) union all (select t8_alias1.c10 from t8 t8_alias1 limit 1);
|
|
c15
|
|
ieLhJAFmNCq00000
|
|
explain (select /*+USE_HASH_AGGREGATION*/ c15 from (select c15 from t8) intersect (select c15 from t8) order by 1 limit 1000) union all (select t8_alias1.c10 from t8 t8_alias1 limit 1);
|
|
Query Plan
|
|
================================================================================
|
|
|ID|OPERATOR |NAME |EST.ROWS|EST.TIME(us)|
|
|
--------------------------------------------------------------------------------
|
|
|0 |UNION ALL | |2 |88 |
|
|
|1 |├─TOP-N SORT | |1 |86 |
|
|
|2 |│ └─HASH INTERSECT DISTINCT | |1 |86 |
|
|
|3 |│ ├─PX COORDINATOR | |1 |43 |
|
|
|4 |│ │ └─EXCHANGE OUT DISTR |:EX10000 |1 |43 |
|
|
|5 |│ │ └─PX PARTITION ITERATOR| |1 |43 |
|
|
|6 |│ │ └─TABLE FULL SCAN |t8 |1 |43 |
|
|
|7 |│ └─PX COORDINATOR | |1 |43 |
|
|
|8 |│ └─EXCHANGE OUT DISTR |:EX20000 |1 |43 |
|
|
|9 |│ └─PX PARTITION ITERATOR| |1 |43 |
|
|
|10|│ └─TABLE FULL SCAN |t8 |1 |43 |
|
|
|11|└─DISTRIBUTED TABLE FULL SCAN |t8_alias1(i_ahayugXY)|1 |3 |
|
|
================================================================================
|
|
Outputs & filters:
|
|
-------------------------------------
|
|
0 - output([UNION([1])]), filter(nil), rowset=16
|
|
1 - output([cast(INTERSECT([1]), VARCHAR(127))]), filter(nil), rowset=16
|
|
sort_keys([INTERSECT([1]), ASC]), topn(1000)
|
|
2 - output([INTERSECT([1])], [cast(INTERSECT([1]), VARCHAR(127))]), filter(nil), rowset=16
|
|
3 - output([t8.c15]), filter(nil), rowset=16
|
|
4 - output([t8.c15]), filter(nil), rowset=16
|
|
dop=1
|
|
5 - output([t8.c15]), filter(nil), rowset=16
|
|
force partition granule
|
|
6 - output([t8.c15]), filter(nil), rowset=16
|
|
access([t8.c15]), partitions(p[0-19])
|
|
is_index_back=false, is_global_index=false,
|
|
range_key([t8.c7], [t8.c6]), range(MIN,MIN ; MAX,MAX)always true
|
|
7 - output([t8.c15]), filter(nil), rowset=16
|
|
8 - output([t8.c15]), filter(nil), rowset=16
|
|
dop=1
|
|
9 - output([t8.c15]), filter(nil), rowset=16
|
|
force partition granule
|
|
10 - output([t8.c15]), filter(nil), rowset=16
|
|
access([t8.c15]), partitions(p[0-19])
|
|
is_index_back=false, is_global_index=false,
|
|
range_key([t8.c7], [t8.c6]), range(MIN,MIN ; MAX,MAX)always true
|
|
11 - output([t8_alias1.c10]), filter(nil), rowset=16
|
|
access([t8_alias1.c10]), partitions(p0)
|
|
limit(1), offset(nil), is_index_back=false, is_global_index=true,
|
|
range_key([t8_alias1.c10], [t8_alias1.c18], [t8_alias1.c7], [t8_alias1.c6]), range(MIN,MIN,MIN,MIN ; MAX,MAX,MAX,MAX)always true
|
|
(select /*+USE_HASH_AGGREGATION*/ c15 from (select c15 from t8) intersect (select c15 from t8) order by 1 limit 1000) union all (select t8_alias1.c10 from t8 t8_alias1 limit 1);
|
|
c15
|
|
0
|
|
ieLhJAFmNCq00000
|
|
drop table t8;
|
|
create table t8 (c1 BINARY(99) ,c2 INTEGER(127) ,c3 VARBINARY(71) ,c4 BINARY(65) ,c5 BIGINT(127) ,c6 INTEGER(127) ,c7 INT(127) ,c8 INTEGER(127) ,c9 NUMERIC(64,25) ,c10 VARBINARY(55) ,c11 BIGINT(127) ,c12 VARCHAR(86) ,c13 INTEGER(127) ,c14 INT(127) ,c15 INTEGER(127) ,c16 DECIMAL(64,15) ,c17 INTEGER(127) ,c18 VARBINARY(76) ,c19 INTEGER(127) , primary key(c7,c6), index i_OkcN(c19), index i_ahayugXY(c10,c18), index i_iA(c16,c2));
|
|
insert into t8 values('cdxLVdvvJjcoHFBECqXKkRGoMXYgNsTpJRrqYaluQdfEeB00000',0,'RetSgyIigYXIPgBXBsmZHQZQPLWcGoELCf00000','wD00000',0,0,0,0,0.0000000000000000000000000,'ieLhJAFmNCq00000',0,'DcKPncNvJjyYcNJKFmVUVhqvgUlLfINbycifYNHjzqALoLfn00000',0,0,0,0.000000000000000,0,'MojimRsQZuotWXMuvSQVDSdCmOaloSXNLRTxMYYXaxGbtuk00000',0);
|
|
explain ((select c6 from t8 where c6 < 1000) except (select c6 from t8 where c6 > -1000) order by c6 limit 1000) union all (select t8_alias1.c10 from t8 t8_alias1 limit 1);
|
|
Query Plan
|
|
=============================================================
|
|
|ID|OPERATOR |NAME |EST.ROWS|EST.TIME(us)|
|
|
-------------------------------------------------------------
|
|
|0 |UNION ALL | |2 |7 |
|
|
|1 |├─TOP-N SORT | |1 |5 |
|
|
|2 |│ └─HASH EXCEPT DISTINCT| |1 |5 |
|
|
|3 |│ ├─TABLE FULL SCAN |t8 |1 |3 |
|
|
|4 |│ └─TABLE FULL SCAN |t8 |1 |3 |
|
|
|5 |└─TABLE FULL SCAN |t8_alias1|1 |3 |
|
|
=============================================================
|
|
Outputs & filters:
|
|
-------------------------------------
|
|
0 - output([UNION([1])]), filter(nil), rowset=16
|
|
1 - output([cast(EXCEPT([1]), VARCHAR(127))]), filter(nil), rowset=16
|
|
sort_keys([EXCEPT([1]), ASC]), topn(1000)
|
|
2 - output([EXCEPT([1])], [cast(EXCEPT([1]), VARCHAR(127))]), filter(nil), rowset=16
|
|
3 - output([t8.c6]), filter([t8.c6 < 1000]), rowset=16
|
|
access([t8.c6]), partitions(p0)
|
|
is_index_back=false, is_global_index=false, filter_before_indexback[false],
|
|
range_key([t8.c7], [t8.c6]), range(MIN,MIN ; MAX,MAX)always true
|
|
4 - output([t8.c6]), filter([t8.c6 > -1000]), rowset=16
|
|
access([t8.c6]), partitions(p0)
|
|
is_index_back=false, is_global_index=false, filter_before_indexback[false],
|
|
range_key([t8.c7], [t8.c6]), range(MIN,MIN ; MAX,MAX)always true
|
|
5 - output([t8_alias1.c10]), filter(nil), rowset=16
|
|
access([t8_alias1.c10]), partitions(p0)
|
|
limit(1), offset(nil), is_index_back=false, is_global_index=false,
|
|
range_key([t8_alias1.c7], [t8_alias1.c6]), range(MIN,MIN ; MAX,MAX)always true
|
|
drop table t1,t2,t3,t4,t5,t6, t8;
|