init push

This commit is contained in:
oceanbase-admin
2021-05-31 22:56:52 +08:00
commit cea7de1475
7020 changed files with 5689869 additions and 0 deletions

View File

@ -0,0 +1,114 @@
drop table if exists t1;
drop table if exists t2;
create table t1(c1 bigint primary key,c2 bigint) partition by hash (c1) partitions 10;
create table t2(c1 bigint primary key,c2 bigint) partition by hash (c1) partitions 6;
insert into t1 values(1,2),(2,3),(3,4),(4,5),(5,6),(6,7),(0,1),(7,8),(8,9),(9,10);
insert into t2 values(1,2),(2,3),(3,4),(4,5),(5,6),(6,7),(0,1),(7,8),(8,9),(9,10);
commit;
explain basic
select /*+ USE_PX parallel(3) */* from
(select c1,count(*) over(partition by c1) c2 from
(select c1,count(c2) c2 from t1 group by c1)c) a join
(select c1,count(*) c2 from t2 group by c1)b on a.c1=b.c1 ;
Query Plan
=============================================
|ID|OPERATOR |NAME |
---------------------------------------------
|0 |PX COORDINATOR | |
|1 | EXCHANGE OUT DISTR |:EX10001|
|2 | MERGE JOIN | |
|3 | EXCHANGE IN MERGE SORT DISTR| |
|4 | EXCHANGE OUT DISTR (PKEY) |:EX10000|
|5 | PX BLOCK ITERATOR | |
|6 | TABLE SCAN |t1 |
|7 | SORT | |
|8 | PX PARTITION ITERATOR | |
|9 | TABLE SCAN |t2 |
=============================================
Outputs & filters:
-------------------------------------
0 - output([t1.c1], [1], [t2.c1], [1]), filter(nil)
1 - output([t1.c1], [t2.c1], [1], [1]), filter(nil), dop=3
2 - output([t1.c1], [t2.c1], [1], [1]), filter(nil),
equal_conds([t1.c1 = t2.c1]), other_conds(nil)
3 - output([t1.c1]), filter(nil), sort_keys([t1.c1, ASC]), Local Order
4 - (#keys=1, [t1.c1]), output([t1.c1]), filter(nil), dop=3
5 - output([t1.c1]), filter(nil)
6 - output([t1.c1]), filter(nil),
access([t1.c1]), partitions(p[0-9])
7 - output([t2.c1]), filter(nil), sort_keys([t2.c1, ASC]), local merge sort
8 - output([t2.c1]), filter(nil)
9 - output([t2.c1]), filter(nil),
access([t2.c1]), partitions(p[0-5])
select /*+ USE_PX parallel(3) */* from
(select c1,count(*) over(partition by c1) c2 from
(select c1,count(c2) c2 from t1 group by c1)c) a join
(select c1,count(*) c2 from t2 group by c1)b on a.c1=b.c1;
c1 c2 c1 c2
0 1 0 1
1 1 1 1
2 1 2 1
3 1 3 1
4 1 4 1
5 1 5 1
6 1 6 1
7 1 7 1
8 1 8 1
9 1 9 1
explain basic
select a.c2,count(*) from (select /*+ USE_PX parallel(3) PQ_DISTRIBUTE(b HASH HASH) */a.c1,a.c2,b.c1 c3,b.c2 c4 from t1 a join t2 b on a.c1=b.c1)a group by a.c2;
Query Plan
================================================
|ID|OPERATOR |NAME |
------------------------------------------------
|0 |PX COORDINATOR | |
|1 | EXCHANGE OUT DISTR |:EX10003|
|2 | HASH GROUP BY | |
|3 | EXCHANGE IN DISTR | |
|4 | EXCHANGE OUT DISTR (HASH) |:EX10002|
|5 | MERGE JOIN | |
|6 | EXCHANGE IN MERGE SORT DISTR| |
|7 | EXCHANGE OUT DISTR (HASH) |:EX10000|
|8 | PX BLOCK ITERATOR | |
|9 | TABLE SCAN |a |
|10| EXCHANGE IN MERGE SORT DISTR| |
|11| EXCHANGE OUT DISTR (HASH) |:EX10001|
|12| PX BLOCK ITERATOR | |
|13| TABLE SCAN |b |
================================================
Outputs & filters:
-------------------------------------
0 - output([a.c2], [T_FUN_COUNT(*)]), filter(nil)
1 - output([a.c2], [T_FUN_COUNT(*)]), filter(nil), dop=3
2 - output([a.c2], [T_FUN_COUNT(*)]), filter(nil),
group([a.c2]), agg_func([T_FUN_COUNT(*)])
3 - output([a.c2]), filter(nil)
4 - (#keys=1, [a.c2]), output([a.c2]), filter(nil), dop=3
5 - output([a.c2]), filter(nil),
equal_conds([a.c1 = b.c1]), other_conds(nil)
6 - output([a.c1], [a.c2]), filter(nil), sort_keys([a.c1, ASC]), Local Order
7 - (#keys=1, [a.c1]), output([a.c1], [a.c2]), filter(nil), dop=3
8 - output([a.c1], [a.c2]), filter(nil)
9 - output([a.c1], [a.c2]), filter(nil),
access([a.c1], [a.c2]), partitions(p[0-9])
10 - output([b.c1]), filter(nil), sort_keys([b.c1, ASC]), Local Order
11 - (#keys=1, [b.c1]), output([b.c1]), filter(nil), dop=3
12 - output([b.c1]), filter(nil)
13 - output([b.c1]), filter(nil),
access([b.c1]), partitions(p[0-5])
select a.c2,count(*) from (select /*+ USE_PX parallel(3) PQ_DISTRIBUTE(b HASH HASH) */a.c1,a.c2,b.c1 c3,b.c2 c4 from t1 a join t2 b on a.c1=b.c1)a group by a.c2;
c2 count(*)
1 1
10 1
2 1
3 1
4 1
5 1
6 1
7 1
8 1
9 1

View File

@ -0,0 +1,227 @@
drop table if exists t1, t2;
create table t1 (c1 int, c2 int, c3 int);
create table t2 (c1 int, c2 int, c3 int);
explain select /*+ use_px parallel(2) use_hash(c d) */ * from (select a.c2, b.c3 from (select /*+ use_hash(a, b) */ c1, c2, count(*) c3 from t1 group by 1, 2) a, (select c1, c2, count(*) c3 from t1 group by 1, 2) b where a.c1 = b.c1) c, (select c1, c2, count(*) c3 from t1 group by 1, 2) d where c.c2 = d.c2;
Query Plan
====================================================================
|ID|OPERATOR |NAME |EST. ROWS|COST |
--------------------------------------------------------------------
|0 |PX COORDINATOR | |96059602 |90225641|
|1 | EXCHANGE OUT DISTR |:EX10005|96059602 |58400112|
|2 | HASH JOIN | |96059602 |58400112|
|3 | EXCHANGE IN DISTR | |10001 |169529 |
|4 | EXCHANGE OUT DISTR (BROADCAST) |:EX10001|10001 |168583 |
|5 | SUBPLAN SCAN |b |10001 |168583 |
|6 | HASH GROUP BY | |10001 |167202 |
|7 | EXCHANGE IN DISTR | |10001 |116107 |
|8 | EXCHANGE OUT DISTR (HASH) |:EX10000|10001 |115161 |
|9 | HASH GROUP BY | |10001 |115161 |
|10| PX BLOCK ITERATOR | |100000 |64066 |
|11| TABLE SCAN |t1 |100000 |64066 |
|12| HASH JOIN | |980101 |924869 |
|13| EXCHANGE IN DISTR | |10001 |158931 |
|14| EXCHANGE OUT DISTR (BROADCAST)|:EX10003|10001 |157984 |
|15| SUBPLAN SCAN |a |10001 |157984 |
|16| HASH GROUP BY | |10001 |156604 |
|17| EXCHANGE IN DISTR | |10001 |110808 |
|18| EXCHANGE OUT DISTR (HASH) |:EX10002|10001 |109862 |
|19| HASH GROUP BY | |10001 |109862 |
|20| PX BLOCK ITERATOR | |100000 |64066 |
|21| TABLE SCAN |t1 |100000 |64066 |
|22| SUBPLAN SCAN |d |10001 |168583 |
|23| HASH GROUP BY | |10001 |167202 |
|24| EXCHANGE IN DISTR | |10001 |116107 |
|25| EXCHANGE OUT DISTR (HASH) |:EX10004|10001 |115161 |
|26| HASH GROUP BY | |10001 |115161 |
|27| PX BLOCK ITERATOR | |100000 |64066 |
|28| TABLE SCAN |t1 |100000 |64066 |
====================================================================
Outputs & filters:
-------------------------------------
0 - output([a.c2], [b.c3], [d.c1], [d.c2], [d.c3]), filter(nil)
1 - output([a.c2], [b.c3], [d.c1], [d.c2], [d.c3]), filter(nil), dop=2
2 - output([a.c2], [b.c3], [d.c1], [d.c2], [d.c3]), filter(nil),
equal_conds([a.c1 = b.c1]), other_conds(nil)
3 - output([b.c1], [b.c3]), filter(nil)
4 - output([b.c1], [b.c3]), filter(nil), dop=2
5 - output([b.c1], [b.c3]), filter(nil),
access([b.c1], [b.c3])
6 - output([t1.c1], [T_FUN_COUNT_SUM(T_FUN_COUNT(*))]), filter(nil),
group([t1.c1], [t1.c2]), agg_func([T_FUN_COUNT_SUM(T_FUN_COUNT(*))])
7 - output([t1.c1], [T_FUN_COUNT(*)], [t1.c2]), filter(nil)
8 - (#keys=2, [t1.c1], [t1.c2]), output([t1.c1], [T_FUN_COUNT(*)], [t1.c2]), filter(nil), dop=2
9 - output([t1.c1], [T_FUN_COUNT(*)], [t1.c2]), filter(nil),
group([t1.c1], [t1.c2]), agg_func([T_FUN_COUNT(*)])
10 - output([t1.c1], [t1.c2]), filter(nil)
11 - output([t1.c1], [t1.c2]), filter(nil),
access([t1.c1], [t1.c2]), partitions(p0)
12 - output([a.c2], [d.c1], [d.c2], [d.c3], [a.c1]), filter(nil),
equal_conds([a.c2 = d.c2]), other_conds(nil)
13 - output([a.c1], [a.c2]), filter(nil)
14 - output([a.c1], [a.c2]), filter(nil), dop=2
15 - output([a.c1], [a.c2]), filter(nil),
access([a.c1], [a.c2])
16 - output([t1.c1], [t1.c2]), filter(nil),
group([t1.c1], [t1.c2]), agg_func(nil)
17 - output([t1.c1], [t1.c2]), filter(nil)
18 - (#keys=2, [t1.c1], [t1.c2]), output([t1.c1], [t1.c2]), filter(nil), dop=2
19 - output([t1.c1], [t1.c2]), filter(nil),
group([t1.c1], [t1.c2]), agg_func(nil)
20 - output([t1.c1], [t1.c2]), filter(nil)
21 - output([t1.c1], [t1.c2]), filter(nil),
access([t1.c1], [t1.c2]), partitions(p0)
22 - output([d.c2], [d.c1], [d.c3]), filter(nil),
access([d.c2], [d.c1], [d.c3])
23 - output([t1.c1], [t1.c2], [T_FUN_COUNT_SUM(T_FUN_COUNT(*))]), filter(nil),
group([t1.c1], [t1.c2]), agg_func([T_FUN_COUNT_SUM(T_FUN_COUNT(*))])
24 - output([t1.c1], [t1.c2], [T_FUN_COUNT(*)]), filter(nil)
25 - (#keys=2, [t1.c1], [t1.c2]), output([t1.c1], [t1.c2], [T_FUN_COUNT(*)]), filter(nil), dop=2
26 - output([t1.c1], [t1.c2], [T_FUN_COUNT(*)]), filter(nil),
group([t1.c1], [t1.c2]), agg_func([T_FUN_COUNT(*)])
27 - output([t1.c1], [t1.c2]), filter(nil)
28 - output([t1.c1], [t1.c2]), filter(nil),
access([t1.c1], [t1.c2]), partitions(p0)
explain select /*+ use_px parallel(2) use_merge(a b) */ b.c2, sum(a.c3) from (select /*+ NO_USE_HASH_AGGREGATION */ c1, c2, count(*) c3 from t1 group by 1, 2) a, t2 b where a.c1 = b.c1 group by 1;
Query Plan
===============================================================================
|ID|OPERATOR |NAME |EST. ROWS|COST |
-------------------------------------------------------------------------------
|0 |PX COORDINATOR | |101 |744726|
|1 | EXCHANGE OUT DISTR |:EX10005|101 |744696|
|2 | MERGE GROUP BY | |101 |744696|
|3 | EXCHANGE IN MERGE SORT DISTR | |101 |742003|
|4 | EXCHANGE OUT DISTR (HASH) |:EX10004|101 |741972|
|5 | MERGE GROUP BY | |101 |741972|
|6 | SORT | |9802 |739279|
|7 | MERGE JOIN | |9802 |712834|
|8 | MATERIAL | |101 |355664|
|9 | EXCHANGE IN MERGE SORT DISTR | |101 |355600|
|10| EXCHANGE OUT DISTR (BROADCAST) |:EX10002|101 |355583|
|11| MATERIAL | |101 |355583|
|12| SUBPLAN SCAN |VIEW1 |101 |355519|
|13| MERGE GROUP BY | |101 |355505|
|14| EXCHANGE IN MERGE SORT DISTR | |101 |352758|
|15| EXCHANGE OUT DISTR (HASH) |:EX10001|101 |352748|
|16| MATERIAL | |101 |352748|
|17| MERGE GROUP BY | |101 |352711|
|18| SUBPLAN SCAN |a |10001 |349964|
|19| MERGE GROUP BY | |10001 |348584|
|20| EXCHANGE IN MERGE SORT DISTR| |10001 |312738|
|21| EXCHANGE OUT DISTR (HASH) |:EX10000|10001 |311791|
|22| MERGE GROUP BY | |10001 |311791|
|23| SORT | |100000 |275945|
|24| PX BLOCK ITERATOR | |100000 |64066 |
|25| TABLE SCAN |t1 |100000 |64066 |
|26| SUBPLAN SCAN |VIEW2 |10001 |349964|
|27| MERGE GROUP BY | |10001 |348584|
|28| EXCHANGE IN MERGE SORT DISTR | |10001 |312738|
|29| EXCHANGE OUT DISTR (HASH) |:EX10003|10001 |311791|
|30| MERGE GROUP BY | |10001 |311791|
|31| SORT | |100000 |275945|
|32| PX BLOCK ITERATOR | |100000 |64066 |
|33| TABLE SCAN |b |100000 |64066 |
===============================================================================
Outputs & filters:
-------------------------------------
0 - output([VIEW2.b.c2], [T_FUN_SUM(T_FUN_SUM(VIEW1.T_FUN_SUM(a.c3) * cast(VIEW2.T_FUN_COUNT(*), DECIMAL(20, 0))))]), filter(nil)
1 - output([VIEW2.b.c2], [T_FUN_SUM(T_FUN_SUM(VIEW1.T_FUN_SUM(a.c3) * cast(VIEW2.T_FUN_COUNT(*), DECIMAL(20, 0))))]), filter(nil), dop=2
2 - output([VIEW2.b.c2], [T_FUN_SUM(T_FUN_SUM(VIEW1.T_FUN_SUM(a.c3) * cast(VIEW2.T_FUN_COUNT(*), DECIMAL(20, 0))))]), filter(nil),
group([VIEW2.b.c2]), agg_func([T_FUN_SUM(T_FUN_SUM(VIEW1.T_FUN_SUM(a.c3) * cast(VIEW2.T_FUN_COUNT(*), DECIMAL(20, 0))))])
3 - output([VIEW2.b.c2], [T_FUN_SUM(VIEW1.T_FUN_SUM(a.c3) * cast(VIEW2.T_FUN_COUNT(*), DECIMAL(20, 0)))]), filter(nil), sort_keys([VIEW2.b.c2, ASC])
4 - (#keys=1, [VIEW2.b.c2]), output([VIEW2.b.c2], [T_FUN_SUM(VIEW1.T_FUN_SUM(a.c3) * cast(VIEW2.T_FUN_COUNT(*), DECIMAL(20, 0)))]), filter(nil), dop=2
5 - output([VIEW2.b.c2], [T_FUN_SUM(VIEW1.T_FUN_SUM(a.c3) * cast(VIEW2.T_FUN_COUNT(*), DECIMAL(20, 0)))]), filter(nil),
group([VIEW2.b.c2]), agg_func([T_FUN_SUM(VIEW1.T_FUN_SUM(a.c3) * cast(VIEW2.T_FUN_COUNT(*), DECIMAL(20, 0)))])
6 - output([VIEW2.b.c2], [VIEW1.T_FUN_SUM(a.c3) * cast(VIEW2.T_FUN_COUNT(*), DECIMAL(20, 0))]), filter(nil), sort_keys([VIEW2.b.c2, ASC])
7 - output([VIEW2.b.c2], [VIEW1.T_FUN_SUM(a.c3)], [VIEW2.T_FUN_COUNT(*)]), filter(nil),
equal_conds([VIEW1.a.c1 = VIEW2.b.c1]), other_conds(nil)
8 - output([VIEW1.T_FUN_SUM(a.c3)], [VIEW1.a.c1]), filter(nil)
9 - output([VIEW1.T_FUN_SUM(a.c3)], [VIEW1.a.c1]), filter(nil), sort_keys([VIEW1.a.c1, ASC])
10 - output([VIEW1.T_FUN_SUM(a.c3)], [VIEW1.a.c1]), filter(nil), dop=2
11 - output([VIEW1.T_FUN_SUM(a.c3)], [VIEW1.a.c1]), filter(nil)
12 - output([VIEW1.a.c1], [VIEW1.T_FUN_SUM(a.c3)]), filter(nil),
access([VIEW1.a.c1], [VIEW1.T_FUN_SUM(a.c3)])
13 - output([a.c1], [T_FUN_SUM(T_FUN_SUM(a.c3))]), filter(nil),
group([a.c1]), agg_func([T_FUN_SUM(T_FUN_SUM(a.c3))])
14 - output([a.c1], [T_FUN_SUM(a.c3)]), filter(nil), sort_keys([a.c1, ASC])
15 - (#keys=1, [a.c1]), output([a.c1], [T_FUN_SUM(a.c3)]), filter(nil), dop=2
16 - output([a.c1], [T_FUN_SUM(a.c3)]), filter(nil)
17 - output([a.c1], [T_FUN_SUM(a.c3)]), filter(nil),
group([a.c1]), agg_func([T_FUN_SUM(a.c3)])
18 - output([a.c1], [a.c3]), filter(nil),
access([a.c1], [a.c3])
19 - output([t1.c1], [T_FUN_COUNT_SUM(T_FUN_COUNT(*))]), filter(nil),
group([t1.c1], [t1.c2]), agg_func([T_FUN_COUNT_SUM(T_FUN_COUNT(*))])
20 - output([t1.c1], [T_FUN_COUNT(*)], [t1.c2]), filter(nil), sort_keys([t1.c1, ASC], [t1.c2, ASC])
21 - (#keys=2, [t1.c1], [t1.c2]), output([t1.c1], [T_FUN_COUNT(*)], [t1.c2]), filter(nil), dop=2
22 - output([t1.c1], [T_FUN_COUNT(*)], [t1.c2]), filter(nil),
group([t1.c1], [t1.c2]), agg_func([T_FUN_COUNT(*)])
23 - output([t1.c1], [t1.c2]), filter(nil), sort_keys([t1.c1, ASC], [t1.c2, ASC])
24 - output([t1.c1], [t1.c2]), filter(nil)
25 - output([t1.c1], [t1.c2]), filter(nil),
access([t1.c1], [t1.c2]), partitions(p0)
26 - output([VIEW2.b.c1], [VIEW2.b.c2], [VIEW2.T_FUN_COUNT(*)]), filter(nil),
access([VIEW2.b.c1], [VIEW2.b.c2], [VIEW2.T_FUN_COUNT(*)])
27 - output([b.c1], [b.c2], [T_FUN_COUNT_SUM(T_FUN_COUNT(*))]), filter(nil),
group([b.c1], [b.c2]), agg_func([T_FUN_COUNT_SUM(T_FUN_COUNT(*))])
28 - output([b.c1], [b.c2], [T_FUN_COUNT(*)]), filter(nil), sort_keys([b.c1, ASC], [b.c2, ASC])
29 - (#keys=2, [b.c1], [b.c2]), output([b.c1], [b.c2], [T_FUN_COUNT(*)]), filter(nil), dop=2
30 - output([b.c1], [b.c2], [T_FUN_COUNT(*)]), filter(nil),
group([b.c1], [b.c2]), agg_func([T_FUN_COUNT(*)])
31 - output([b.c1], [b.c2]), filter(nil), sort_keys([b.c1, ASC], [b.c2, ASC])
32 - output([b.c1], [b.c2]), filter(nil)
33 - output([b.c1], [b.c2]), filter(nil),
access([b.c1], [b.c2]), partitions(p0)
explain select /*+ use_px parallel(2) use_merge(a b) */ * from (select /*+ NO_USE_HASH_AGGREGATION */ c1, c2, count(*) c3 from t1 group by 1, 2) a, t2 b where a.c1 = b.c1;
Query Plan
====================================================================
|ID|OPERATOR |NAME |EST. ROWS|COST |
--------------------------------------------------------------------
|0 |PX COORDINATOR | |9801001 |9264343|
|1 | EXCHANGE OUT DISTR |:EX10002|9801001 |6481053|
|2 | MERGE JOIN | |9801001 |6481053|
|3 | EXCHANGE IN MERGE SORT DISTR | |10001 |356896 |
|4 | EXCHANGE OUT DISTR (BROADCAST) |:EX10001|10001 |355477 |
|5 | MATERIAL | |10001 |355477 |
|6 | SUBPLAN SCAN |a |10001 |349964 |
|7 | MERGE GROUP BY | |10001 |348584 |
|8 | EXCHANGE IN MERGE SORT DISTR| |10001 |312738 |
|9 | EXCHANGE OUT DISTR (HASH) |:EX10000|10001 |311791 |
|10| MERGE GROUP BY | |10001 |311791 |
|11| SORT | |100000 |275945 |
|12| PX BLOCK ITERATOR | |100000 |64066 |
|13| TABLE SCAN |t1 |100000 |64066 |
|14| SORT | |100000 |296180 |
|15| PX BLOCK ITERATOR | |100000 |66272 |
|16| TABLE SCAN |b |100000 |66272 |
====================================================================
Outputs & filters:
-------------------------------------
0 - output([a.c1], [a.c2], [a.c3], [b.c1], [b.c2], [b.c3]), filter(nil)
1 - output([a.c1], [a.c2], [a.c3], [b.c1], [b.c2], [b.c3]), filter(nil), dop=2
2 - output([a.c1], [a.c2], [a.c3], [b.c1], [b.c2], [b.c3]), filter(nil),
equal_conds([a.c1 = b.c1]), other_conds(nil)
3 - output([a.c1], [a.c2], [a.c3]), filter(nil), sort_keys([a.c1, ASC])
4 - output([a.c1], [a.c2], [a.c3]), filter(nil), dop=2
5 - output([a.c1], [a.c2], [a.c3]), filter(nil)
6 - output([a.c1], [a.c2], [a.c3]), filter(nil),
access([a.c1], [a.c2], [a.c3])
7 - output([t1.c1], [t1.c2], [T_FUN_COUNT_SUM(T_FUN_COUNT(*))]), filter(nil),
group([t1.c1], [t1.c2]), agg_func([T_FUN_COUNT_SUM(T_FUN_COUNT(*))])
8 - output([t1.c1], [t1.c2], [T_FUN_COUNT(*)]), filter(nil), sort_keys([t1.c1, ASC], [t1.c2, ASC])
9 - (#keys=2, [t1.c1], [t1.c2]), output([t1.c1], [t1.c2], [T_FUN_COUNT(*)]), filter(nil), dop=2
10 - output([t1.c1], [t1.c2], [T_FUN_COUNT(*)]), filter(nil),
group([t1.c1], [t1.c2]), agg_func([T_FUN_COUNT(*)])
11 - output([t1.c1], [t1.c2]), filter(nil), sort_keys([t1.c1, ASC], [t1.c2, ASC])
12 - output([t1.c1], [t1.c2]), filter(nil)
13 - output([t1.c1], [t1.c2]), filter(nil),
access([t1.c1], [t1.c2]), partitions(p0)
14 - output([b.c1], [b.c2], [b.c3]), filter(nil), sort_keys([b.c1, ASC])
15 - output([b.c1], [b.c2], [b.c3]), filter(nil)
16 - output([b.c1], [b.c2], [b.c3]), filter(nil),
access([b.c1], [b.c2], [b.c3]), partitions(p0)

View File

@ -0,0 +1,130 @@
drop database if exists muhangtest;
drop table if exists t1;
create database muhangtest;
use muhangtest;
create table t1 (c1 int(11) not null, c2 int(11) not null, c3 int(11) not null, primary key (c1, c2, c3)) partition by key(c2) partitions 4;
explain select * from t1;
Query Plan
======================================================
|ID|OPERATOR |NAME |EST. ROWS|COST |
------------------------------------------------------
|0 |PX COORDINATOR | |400000 |313022|
|1 | EXCHANGE OUT DISTR |:EX10000|400000 |256226|
|2 | PX PARTITION ITERATOR| |400000 |256226|
|3 | TABLE SCAN |t1 |400000 |256226|
======================================================
Outputs & filters:
-------------------------------------
0 - output([t1.c1], [t1.c2], [t1.c3]), filter(nil)
1 - output([t1.c2], [t1.c1], [t1.c3]), filter(nil), dop=1
2 - output([t1.c2], [t1.c1], [t1.c3]), filter(nil)
3 - output([t1.c2], [t1.c1], [t1.c3]), filter(nil),
access([t1.c2], [t1.c1], [t1.c3]), partitions(p[0-3])
explain select /*+use_px*/ * from t1;
Query Plan
======================================================
|ID|OPERATOR |NAME |EST. ROWS|COST |
------------------------------------------------------
|0 |PX COORDINATOR | |400000 |313022|
|1 | EXCHANGE OUT DISTR |:EX10000|400000 |256226|
|2 | PX PARTITION ITERATOR| |400000 |256226|
|3 | TABLE SCAN |t1 |400000 |256226|
======================================================
Outputs & filters:
-------------------------------------
0 - output([t1.c1], [t1.c2], [t1.c3]), filter(nil)
1 - output([t1.c2], [t1.c1], [t1.c3]), filter(nil), dop=1
2 - output([t1.c2], [t1.c1], [t1.c3]), filter(nil)
3 - output([t1.c2], [t1.c1], [t1.c3]), filter(nil),
access([t1.c2], [t1.c1], [t1.c3]), partitions(p[0-3])
explain select /*+use_px parallel(15)*/ * from t1;
Query Plan
==================================================
|ID|OPERATOR |NAME |EST. ROWS|COST |
--------------------------------------------------
|0 |PX COORDINATOR | |400000 |313022|
|1 | EXCHANGE OUT DISTR|:EX10000|400000 |256226|
|2 | PX BLOCK ITERATOR| |400000 |256226|
|3 | TABLE SCAN |t1 |400000 |256226|
==================================================
Outputs & filters:
-------------------------------------
0 - output([t1.c1], [t1.c2], [t1.c3]), filter(nil)
1 - output([t1.c2], [t1.c1], [t1.c3]), filter(nil), dop=15
2 - output([t1.c2], [t1.c1], [t1.c3]), filter(nil)
3 - output([t1.c2], [t1.c1], [t1.c3]), filter(nil),
access([t1.c2], [t1.c1], [t1.c3]), partitions(p[0-3])
explain select /*+no_use_px */ * from t1;
Query Plan
======================================================
|ID|OPERATOR |NAME |EST. ROWS|COST |
------------------------------------------------------
|0 |PX COORDINATOR | |400000 |313022|
|1 | EXCHANGE OUT DISTR |:EX10000|400000 |256226|
|2 | PX PARTITION ITERATOR| |400000 |256226|
|3 | TABLE SCAN |t1 |400000 |256226|
======================================================
Outputs & filters:
-------------------------------------
0 - output([t1.c1], [t1.c2], [t1.c3]), filter(nil)
1 - output([t1.c2], [t1.c1], [t1.c3]), filter(nil), dop=1
2 - output([t1.c2], [t1.c1], [t1.c3]), filter(nil)
3 - output([t1.c2], [t1.c1], [t1.c3]), filter(nil),
access([t1.c2], [t1.c1], [t1.c3]), partitions(p[0-3])
explain select /*+no_use_px use_px*/ * from t1;
Query Plan
======================================================
|ID|OPERATOR |NAME |EST. ROWS|COST |
------------------------------------------------------
|0 |PX COORDINATOR | |400000 |313022|
|1 | EXCHANGE OUT DISTR |:EX10000|400000 |256226|
|2 | PX PARTITION ITERATOR| |400000 |256226|
|3 | TABLE SCAN |t1 |400000 |256226|
======================================================
Outputs & filters:
-------------------------------------
0 - output([t1.c1], [t1.c2], [t1.c3]), filter(nil)
1 - output([t1.c2], [t1.c1], [t1.c3]), filter(nil), dop=1
2 - output([t1.c2], [t1.c1], [t1.c3]), filter(nil)
3 - output([t1.c2], [t1.c1], [t1.c3]), filter(nil),
access([t1.c2], [t1.c1], [t1.c3]), partitions(p[0-3])
explain select /*+use_px no_use_px */ * from t1;
Query Plan
======================================================
|ID|OPERATOR |NAME |EST. ROWS|COST |
------------------------------------------------------
|0 |PX COORDINATOR | |400000 |313022|
|1 | EXCHANGE OUT DISTR |:EX10000|400000 |256226|
|2 | PX PARTITION ITERATOR| |400000 |256226|
|3 | TABLE SCAN |t1 |400000 |256226|
======================================================
Outputs & filters:
-------------------------------------
0 - output([t1.c1], [t1.c2], [t1.c3]), filter(nil)
1 - output([t1.c2], [t1.c1], [t1.c3]), filter(nil), dop=1
2 - output([t1.c2], [t1.c1], [t1.c3]), filter(nil)
3 - output([t1.c2], [t1.c1], [t1.c3]), filter(nil),
access([t1.c2], [t1.c1], [t1.c3]), partitions(p[0-3])
drop table if exists t7;
create table t7(a int, b int, c int, d int, primary key (a)) partition by hash(a) partitions 3;
insert into t7 values(1,2,3,4);
insert into t7 values(2,3,5,6);
select /*+NO_REWRITE use_px */ * from t7 as A, t7 as B where A.a = B.a and exists(select * from t7 where t7.a=B.a);
a b c d a b c d
1 2 3 4 1 2 3 4
2 3 5 6 2 3 5 6
drop table if exists t1;
drop table if exists t7;
drop database if exists muhangtest;

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,129 @@
set ob_query_timeout=1000000000;
drop database if exists px_test;
create database px_test;
use px_test;
create table stu (
sid int,
name varchar(32),
cls int,
primary key (cls, sid)
) partition by hash(sid) partitions 6;
create table teacher (
tid int,
name varchar(32),
subject varchar(4),
primary key (tid)
) partition by hash(tid) partitions 8;
create table score (
sid int,
subject varchar(4),
score int,
primary key (sid, subject)
) partition by hash(sid) partitions 6;
insert into stu values
(11, 'a1', 1),
(12, 'b1', 1),
(13, 'c1', 1),
(21, 'a2', 2),
(22, 'b2', 2),
(31, 'a3', 3),
(41, 'a4', 4),
(42, 'b4', 4),
(51, 'a5', 5),
(52, 'b5', 5),
(61, 'a6', 6),
(62, 'b6', 6),
(63, 'c6', 6),
(64, 'd6', 6);
insert into teacher values
(1, 'Miss Zhang', 'EN'),
(2, 'Mr Wang', 'MA');
insert into score values
(11, 'EN', 60),
(12, 'EN', 70),
(13, 'EN', 80),
(21, 'EN', 58),
(22, 'EN', 90),
(31, 'EN', 80),
(41, 'EN', 80),
(42, 'EN', 90),
(51, 'EN', 89),
(52, 'EN', 99),
(61, 'EN', 100),
(62, 'EN', 90),
(63, 'EN', 99),
(64, 'EN', 87);
insert into score values
(11, 'MA', 60),
(12, 'MA', 70),
(13, 'MA', 80),
(21, 'MA', 58),
(22, 'MA', 90),
(31, 'MA', 80),
(41, 'MA', 80),
(42, 'MA', 90),
(51, 'MA', 89),
(52, 'MA', 99),
(61, 'MA', 100),
(62, 'MA', 90),
(63, 'MA', 99),
(64, 'MA', 87);
explain select /*+ USE_PX parallel(2) */ * from stu, score where stu.sid = score.sid order by score.sid;
Query Plan
=======================================================
|ID|OPERATOR |NAME |EST. ROWS|COST|
-------------------------------------------------------
|0 |PX COORDINATOR MERGE SORT | |12 |145 |
|1 | EXCHANGE OUT DISTR |:EX10000|12 |140 |
|2 | SORT | |12 |140 |
|3 | PX PARTITION ITERATOR | |12 |113 |
|4 | MERGE JOIN | |12 |113 |
|5 | TABLE SCAN |score |24 |41 |
|6 | SORT | |12 |60 |
|7 | TABLE SCAN |stu |12 |39 |
=======================================================
Outputs & filters:
-------------------------------------
0 - output([stu.sid], [stu.name], [stu.cls], [score.sid], [score.subject], [score.score]), filter(nil), sort_keys([score.sid, ASC])
1 - output([stu.sid], [stu.name], [stu.cls], [score.sid], [score.subject], [score.score]), filter(nil), dop=2
2 - output([stu.sid], [stu.name], [stu.cls], [score.sid], [score.subject], [score.score]), filter(nil), sort_keys([score.sid, ASC]), local merge sort
3 - output([stu.sid], [stu.name], [stu.cls], [score.sid], [score.subject], [score.score]), filter(nil)
4 - output([stu.sid], [stu.name], [stu.cls], [score.sid], [score.subject], [score.score]), filter(nil),
equal_conds([stu.sid = score.sid]), other_conds(nil)
5 - output([score.sid], [score.subject], [score.score]), filter(nil),
access([score.sid], [score.subject], [score.score]), partitions(p[0-5])
6 - output([stu.sid], [stu.name], [stu.cls]), filter(nil), sort_keys([stu.sid, ASC])
7 - output([stu.sid], [stu.name], [stu.cls]), filter(nil),
access([stu.sid], [stu.name], [stu.cls]), partitions(p[0-5])
select /*+ USE_PX parallel(2) */ * from stu, score where stu.sid = score.sid order by score.sid;
sid name cls sid subject score
11 a1 1 11 EN 60
11 a1 1 11 MA 60
12 b1 1 12 EN 70
12 b1 1 12 MA 70
13 c1 1 13 EN 80
13 c1 1 13 MA 80
21 a2 2 21 EN 58
21 a2 2 21 MA 58
22 b2 2 22 EN 90
22 b2 2 22 MA 90
31 a3 3 31 EN 80
31 a3 3 31 MA 80
41 a4 4 41 EN 80
41 a4 4 41 MA 80
42 b4 4 42 EN 90
42 b4 4 42 MA 90
51 a5 5 51 EN 89
51 a5 5 51 MA 89
52 b5 5 52 EN 99
52 b5 5 52 MA 99
61 a6 6 61 EN 100
61 a6 6 61 MA 100
62 b6 6 62 EN 90
62 b6 6 62 MA 90
63 c6 6 63 EN 99
63 c6 6 63 MA 99
64 d6 6 64 EN 87
64 d6 6 64 MA 87

View File

@ -0,0 +1,210 @@
set ob_query_timeout=1000000000;
drop database if exists px_test;
create database px_test;
use px_test;
create table stu (
sid int,
name varchar(32),
cls int,
primary key (cls, sid)
) partition by hash(sid) partitions 6;
create table teacher (
tid int,
name varchar(32),
subject varchar(4),
primary key (tid)
) partition by hash(tid) partitions 8;
create table score (
sid int,
subject varchar(4),
score int,
primary key (sid, subject)
) partition by hash(sid) partitions 6;
insert into stu values
(11, 'a1', 1),
(12, 'b1', 1),
(13, 'c1', 1),
(21, 'a2', 2),
(22, 'b2', 2),
(31, 'a3', 3),
(41, 'a4', 4),
(42, 'b4', 4),
(51, 'a5', 5),
(52, 'b5', 5),
(61, 'a6', 6),
(62, 'b6', 6),
(63, 'c6', 6),
(64, 'd6', 6);
insert into teacher values
(1, 'Miss Zhang', 'EN'),
(2, 'Mr Wang', 'MA');
insert into score values
(11, 'EN', 60),
(12, 'EN', 70),
(13, 'EN', 80),
(21, 'EN', 58),
(22, 'EN', 90),
(31, 'EN', 80),
(41, 'EN', 80),
(42, 'EN', 90),
(51, 'EN', 89),
(52, 'EN', 99),
(61, 'EN', 100),
(62, 'EN', 90),
(63, 'EN', 99),
(64, 'EN', 87);
insert into score values
(11, 'MA', 60),
(12, 'MA', 70),
(13, 'MA', 80),
(21, 'MA', 58),
(22, 'MA', 90),
(31, 'MA', 80),
(41, 'MA', 80),
(42, 'MA', 90),
(51, 'MA', 89),
(52, 'MA', 99),
(61, 'MA', 100),
(62, 'MA', 90),
(63, 'MA', 99),
(64, 'MA', 87);
explain select /*+ USE_PX parallel(2) */ * from stu, score where stu.sid != score.sid and stu.sid < 12;
Query Plan
================================================================
|ID|OPERATOR |NAME |EST. ROWS|COST|
----------------------------------------------------------------
|0 |PX COORDINATOR | |15 |106 |
|1 | EXCHANGE OUT DISTR |:EX10001|15 |100 |
|2 | NESTED-LOOP JOIN | |15 |100 |
|3 | PX BLOCK ITERATOR | |24 |41 |
|4 | TABLE SCAN |score |24 |41 |
|5 | MATERIAL | |2 |42 |
|6 | EXCHANGE IN DISTR | |2 |41 |
|7 | EXCHANGE OUT DISTR (BROADCAST)|:EX10000|2 |41 |
|8 | PX BLOCK ITERATOR | |2 |41 |
|9 | TABLE SCAN |stu |2 |41 |
================================================================
Outputs & filters:
-------------------------------------
0 - output([stu.sid], [stu.name], [stu.cls], [score.sid], [score.subject], [score.score]), filter(nil)
1 - output([stu.sid], [stu.name], [stu.cls], [score.sid], [score.subject], [score.score]), filter(nil), dop=2
2 - output([stu.sid], [stu.name], [stu.cls], [score.sid], [score.subject], [score.score]), filter(nil),
conds([stu.sid != score.sid]), nl_params_(nil)
3 - output([score.sid], [score.subject], [score.score]), filter(nil)
4 - output([score.sid], [score.subject], [score.score]), filter(nil),
access([score.sid], [score.subject], [score.score]), partitions(p[0-5])
5 - output([stu.sid], [stu.name], [stu.cls]), filter(nil)
6 - output([stu.sid], [stu.name], [stu.cls]), filter(nil)
7 - output([stu.sid], [stu.name], [stu.cls]), filter(nil), dop=2
8 - output([stu.sid], [stu.name], [stu.cls]), filter(nil)
9 - output([stu.sid], [stu.name], [stu.cls]), filter([stu.sid < 12]),
access([stu.sid], [stu.name], [stu.cls]), partitions(p[0-5])
select /*+ USE_PX parallel(2) */ * from stu, score where stu.sid != score.sid and stu.sid < 12;
sid name cls sid subject score
11 a1 1 12 EN 70
11 a1 1 12 MA 70
11 a1 1 13 EN 80
11 a1 1 13 MA 80
11 a1 1 21 EN 58
11 a1 1 21 MA 58
11 a1 1 22 EN 90
11 a1 1 22 MA 90
11 a1 1 31 EN 80
11 a1 1 31 MA 80
11 a1 1 41 EN 80
11 a1 1 41 MA 80
11 a1 1 42 EN 90
11 a1 1 42 MA 90
11 a1 1 51 EN 89
11 a1 1 51 MA 89
11 a1 1 52 EN 99
11 a1 1 52 MA 99
11 a1 1 61 EN 100
11 a1 1 61 MA 100
11 a1 1 62 EN 90
11 a1 1 62 MA 90
11 a1 1 63 EN 99
11 a1 1 63 MA 99
11 a1 1 64 EN 87
11 a1 1 64 MA 87
explain select /*+ USE_PX parallel(2) */ * from score, teacher where teacher.subject = score.subject and teacher.tid = 1;
Query Plan
===============================================================
|ID|OPERATOR |NAME |EST. ROWS|COST|
---------------------------------------------------------------
|0 |PX COORDINATOR | |1 |109 |
|1 | EXCHANGE OUT DISTR |:EX10001|1 |109 |
|2 | NESTED-LOOP JOIN | |1 |109 |
|3 | EXCHANGE IN DISTR | |1 |53 |
|4 | EXCHANGE OUT DISTR (BROADCAST)|:EX10000|1 |53 |
|5 | PX BLOCK ITERATOR | |1 |53 |
|6 | TABLE GET |teacher |1 |53 |
|7 | PX BLOCK ITERATOR | |24 |41 |
|8 | TABLE SCAN |score |24 |41 |
===============================================================
Outputs & filters:
-------------------------------------
0 - output([score.sid], [score.subject], [score.score], [teacher.tid], [teacher.name], [teacher.subject]), filter(nil)
1 - output([score.sid], [score.subject], [score.score], [teacher.tid], [teacher.name], [teacher.subject]), filter(nil), dop=2
2 - output([score.sid], [score.subject], [score.score], [teacher.tid], [teacher.name], [teacher.subject]), filter(nil),
conds([teacher.subject = score.subject]), nl_params_(nil)
3 - output([teacher.tid], [teacher.subject], [teacher.name]), filter(nil)
4 - output([teacher.tid], [teacher.subject], [teacher.name]), filter(nil), dop=2
5 - output([teacher.tid], [teacher.subject], [teacher.name]), filter(nil)
6 - output([teacher.tid], [teacher.subject], [teacher.name]), filter(nil),
access([teacher.tid], [teacher.subject], [teacher.name]), partitions(p1)
7 - output([score.sid], [score.subject], [score.score]), filter(nil)
8 - output([score.sid], [score.subject], [score.score]), filter(nil),
access([score.sid], [score.subject], [score.score]), partitions(p[0-5])
select /*+ USE_PX parallel(2) */ * from score, teacher where teacher.subject = score.subject and teacher.tid = 1;
sid subject score tid name subject
11 EN 60 1 Miss Zhang EN
12 EN 70 1 Miss Zhang EN
13 EN 80 1 Miss Zhang EN
21 EN 58 1 Miss Zhang EN
22 EN 90 1 Miss Zhang EN
31 EN 80 1 Miss Zhang EN
41 EN 80 1 Miss Zhang EN
42 EN 90 1 Miss Zhang EN
51 EN 89 1 Miss Zhang EN
52 EN 99 1 Miss Zhang EN
61 EN 100 1 Miss Zhang EN
62 EN 90 1 Miss Zhang EN
63 EN 99 1 Miss Zhang EN
64 EN 87 1 Miss Zhang EN
CREATE TABLE product (pid bigint primary key,pname varchar(50),gmt_modify timestamp(6),gmt_create timestamp(6),thread_id bigint, key k (gmt_modify))duplicate_scope="cluster";
CREATE TABLE orders (oid bigint primary key,pid bigint,amount int, addr varchar(20),key k (pid) local) partition by hash (oid) partitions 100;
insert into product values(314265, "abcd", now(), now(), 1234);
insert into orders values(314265, 314265, 678, "192.168.1.8");
insert into product values(314266, "abcd", now(), now(), 1234);
insert into orders values(314266, 314266, 678, "192.168.1.8");
insert into product values(314267, "abcd", now(), now(), 1234);
insert into orders values(314267, 314267, 678, "192.168.1.8");
insert into product values(314268, "abcd", now(), now(), 1234);
insert into orders values(314268, 314268, 678, "192.168.1.8");
explain select t1.pname,t2.oid,t2.amount from product t1,orders t2 where t2.oid = 314265 and t1.pid=t2.pid;
Query Plan
=========================================
|ID|OPERATOR |NAME|EST. ROWS|COST|
-----------------------------------------
|0 |NESTED-LOOP JOIN| |1 |89 |
|1 | TABLE GET |t2 |1 |53 |
|2 | TABLE GET |t1 |1 |36 |
=========================================
Outputs & filters:
-------------------------------------
0 - output([t1.pname], [t2.oid], [t2.amount]), filter(nil),
conds(nil), nl_params_([t2.pid])
1 - output([t2.oid], [t2.pid], [t2.amount]), filter(nil),
access([t2.oid], [t2.pid], [t2.amount]), partitions(p65)
2 - output([t1.pname]), filter(nil),
access([t1.pname]), partitions(p0)
select t1.pname,t2.oid,t2.amount from product t1,orders t2 where t2.oid = 314265 and t1.pid=t2.pid;
pname oid amount
abcd 314265 678

View File

@ -0,0 +1,127 @@
set ob_query_timeout=1000000000;
drop database if exists px_test;
create database px_test;
use px_test;
create table stu (
sid int,
name varchar(32),
cls int,
primary key (cls, sid)
) partition by hash(sid) partitions 6;
create table teacher (
tid int,
name varchar(32),
subject varchar(4),
primary key (tid)
) partition by hash(tid) partitions 8;
create table score (
sid int,
subject varchar(4),
score int,
primary key (sid, subject)
) partition by hash(sid) partitions 6;
insert into stu values
(11, 'a1', 1),
(12, 'b1', 1),
(13, 'c1', 1),
(21, 'a2', 2),
(22, 'b2', 2),
(31, 'a3', 3),
(41, 'a4', 4),
(42, 'b4', 4),
(51, 'a5', 5),
(52, 'b5', 5),
(61, 'a6', 6),
(62, 'b6', 6),
(63, 'c6', 6),
(64, 'd6', 6);
insert into teacher values
(1, 'Miss Zhang', 'EN'),
(2, 'Mr Wang', 'MA');
insert into score values
(11, 'EN', 60),
(12, 'EN', 70),
(13, 'EN', 80),
(21, 'EN', 58),
(22, 'EN', 90),
(31, 'EN', 80),
(41, 'EN', 80),
(42, 'EN', 90),
(51, 'EN', 89),
(52, 'EN', 99),
(61, 'EN', 100),
(62, 'EN', 90),
(63, 'EN', 99),
(64, 'EN', 87);
insert into score values
(11, 'MA', 60),
(12, 'MA', 70),
(13, 'MA', 80),
(21, 'MA', 58),
(22, 'MA', 90),
(31, 'MA', 80),
(41, 'MA', 80),
(42, 'MA', 90),
(51, 'MA', 89),
(52, 'MA', 99),
(61, 'MA', 100),
(62, 'MA', 90),
(63, 'MA', 99),
(64, 'MA', 87);
explain select /*+ USE_PX parallel(2) */ * from stu, score where stu.sid = score.sid;
Query Plan
====================================================
|ID|OPERATOR |NAME |EST. ROWS|COST|
----------------------------------------------------
|0 |PX COORDINATOR | |12 |118 |
|1 | EXCHANGE OUT DISTR |:EX10000|12 |113 |
|2 | PX PARTITION ITERATOR| |12 |113 |
|3 | MERGE JOIN | |12 |113 |
|4 | SORT | |12 |60 |
|5 | TABLE SCAN |stu |12 |39 |
|6 | TABLE SCAN |score |24 |41 |
====================================================
Outputs & filters:
-------------------------------------
0 - output([stu.sid], [stu.name], [stu.cls], [score.sid], [score.subject], [score.score]), filter(nil)
1 - output([stu.sid], [stu.name], [stu.cls], [score.sid], [score.subject], [score.score]), filter(nil), dop=2
2 - output([stu.sid], [stu.name], [stu.cls], [score.sid], [score.subject], [score.score]), filter(nil)
3 - output([stu.sid], [stu.name], [stu.cls], [score.sid], [score.subject], [score.score]), filter(nil),
equal_conds([stu.sid = score.sid]), other_conds(nil)
4 - output([stu.sid], [stu.name], [stu.cls]), filter(nil), sort_keys([stu.sid, ASC])
5 - output([stu.sid], [stu.name], [stu.cls]), filter(nil),
access([stu.sid], [stu.name], [stu.cls]), partitions(p[0-5])
6 - output([score.sid], [score.subject], [score.score]), filter(nil),
access([score.sid], [score.subject], [score.score]), partitions(p[0-5])
select /*+ USE_PX parallel(2) */ * from stu, score where stu.sid = score.sid;
sid name cls sid subject score
11 a1 1 11 EN 60
11 a1 1 11 MA 60
12 b1 1 12 EN 70
12 b1 1 12 MA 70
13 c1 1 13 EN 80
13 c1 1 13 MA 80
21 a2 2 21 EN 58
21 a2 2 21 MA 58
22 b2 2 22 EN 90
22 b2 2 22 MA 90
31 a3 3 31 EN 80
31 a3 3 31 MA 80
41 a4 4 41 EN 80
41 a4 4 41 MA 80
42 b4 4 42 EN 90
42 b4 4 42 MA 90
51 a5 5 51 EN 89
51 a5 5 51 MA 89
52 b5 5 52 EN 99
52 b5 5 52 MA 99
61 a6 6 61 EN 100
61 a6 6 61 MA 100
62 b6 6 62 EN 90
62 b6 6 62 MA 90
63 c6 6 63 EN 99
63 c6 6 63 MA 99
64 d6 6 64 EN 87
64 d6 6 64 MA 87

View File

@ -0,0 +1,98 @@
set ob_query_timeout=1000000000;
drop database if exists px_test;
create database px_test;
use px_test;
create table stu (
sid int,
name varchar(32),
cls int,
primary key (cls, sid)
) partition by hash(sid) partitions 6;
create table teacher (
tid int,
name varchar(32),
subject varchar(4),
primary key (tid)
) partition by hash(tid) partitions 8;
create table score (
sid int,
subject varchar(4),
score int,
primary key (sid, subject)
) partition by hash(sid) partitions 6;
insert into stu values
(11, 'a1', 1),
(12, 'b1', 1),
(13, 'c1', 1),
(21, 'a2', 2),
(22, 'b2', 2),
(31, 'a3', 3),
(41, 'a4', 4),
(42, 'b4', 4),
(51, 'a5', 5),
(52, 'b5', 5),
(61, 'a6', 6),
(62, 'b6', 6),
(63, 'c6', 6),
(64, 'd6', 6);
insert into teacher values
(1, 'Miss Zhang', 'EN'),
(2, 'Mr Wang', 'MA');
insert into score values
(11, 'EN', 60),
(12, 'EN', 70),
(13, 'EN', 80),
(21, 'EN', 58),
(22, 'EN', 90),
(31, 'EN', 80),
(41, 'EN', 80),
(42, 'EN', 90),
(51, 'EN', 89),
(52, 'EN', 99),
(61, 'EN', 100),
(62, 'EN', 90),
(63, 'EN', 99),
(64, 'EN', 87);
insert into score values
(11, 'MA', 60),
(12, 'MA', 70),
(13, 'MA', 80),
(21, 'MA', 58),
(22, 'MA', 90),
(31, 'MA', 80),
(41, 'MA', 80),
(42, 'MA', 90),
(51, 'MA', 89),
(52, 'MA', 99),
(61, 'MA', 100),
(62, 'MA', 90),
(63, 'MA', 99),
(64, 'MA', 87);
connect obsys,$OBMYSQL_MS0,admin,$OBMYSQL_PWD,test,$OBMYSQL_PORT;
connection obsys;
alter system set enable_sql_audit = true;
alter system flush sql audit global;
disconnect obsys;
connection default;
select /*+ TEST_SQL_AUDIT USE_PX parallel(2) */ * from teacher;
select /*+ TEST_SQL_AUDIT USE_PX parallel(3) */ * from teacher;
select /*+ TEST_SQL_AUDIT USE_PX parallel(4) */ * from teacher;
select /*+ TEST_SQL_AUDIT USE_PX parallel(2) */ subject, avg(score), max(score), min(score) from score group by subject;
select /*+ TEST_SQL_AUDIT USE_PX parallel(2) */ cls, subject, avg(score), max(score), min(score) from score join stu using (sid) group by cls, subject;
select /*+ TEST_SQL_AUDIT USE_PX parallel(2) */ count(*) from score join stu using (sid) inner join teacher where score.subject = teacher.subject;
select /*+ TEST_SQL_AUDIT USE_PX parallel(3) */ subject, avg(score), max(score), min(score) from score group by subject;
select /*+ TEST_SQL_AUDIT USE_PX parallel(3) */ cls, subject, avg(score), max(score), min(score) from score join stu using (sid) group by cls, subject;
select /*+ TEST_SQL_AUDIT USE_PX parallel(3) */ count(*) from score join stu using (sid) inner join teacher where score.subject = teacher.subject;
connect obsys,$OBMYSQL_MS0,admin,$OBMYSQL_PWD,test,$OBMYSQL_PORT;
connection obsys;
select query_sql, EXPECTED_WORKER_COUNT, USED_WORKER_COUNT from oceanbase.gv$sql_audit where EXPECTED_WORKER_COUNT > 0 AND query_sql like '%TEST_SQL_AUDIT%' order by request_time desc limit 10;
query_sql EXPECTED_WORKER_COUNT USED_WORKER_COUNT
select /*+ TEST_SQL_AUDIT USE_PX parallel(2) */ * from teacher 2 2
select /*+ TEST_SQL_AUDIT USE_PX parallel(2) */ cls, subject, avg(score), max(score), min(score) from score join stu using (sid) group by cls, subject 4 4
select /*+ TEST_SQL_AUDIT USE_PX parallel(2) */ count(*) from score join stu using (sid) inner join teacher where score.subject = teacher.subject 4 4
select /*+ TEST_SQL_AUDIT USE_PX parallel(2) */ subject, avg(score), max(score), min(score) from score group by subject 4 4
select /*+ TEST_SQL_AUDIT USE_PX parallel(3) */ * from teacher 3 3
select /*+ TEST_SQL_AUDIT USE_PX parallel(3) */ cls, subject, avg(score), max(score), min(score) from score join stu using (sid) group by cls, subject 6 6
select /*+ TEST_SQL_AUDIT USE_PX parallel(3) */ count(*) from score join stu using (sid) inner join teacher where score.subject = teacher.subject 6 6
select /*+ TEST_SQL_AUDIT USE_PX parallel(3) */ subject, avg(score), max(score), min(score) from score group by subject 6 6
select /*+ TEST_SQL_AUDIT USE_PX parallel(4) */ * from teacher 4 4