patch 4.0
This commit is contained in:
@ -1,25 +1,28 @@
|
||||
#################################### test for Used Hint ################################
|
||||
|
||||
#测试rewrite时subquery中的qb_name是否正确
|
||||
select * from t4 where c1 in (select c1 from t1);
|
||||
|
||||
|
||||
### 测试rewrite时指定hint是否生效 ###
|
||||
## subquery 被提升的情况
|
||||
select /*+INDEX(@"SEL$2" "opt.t4"@"SEL$2" "idx_t4_c3")*/* from t1 where c1 in (select c1 from t4);
|
||||
select * from t1 where c1 in (select c1 from t4);
|
||||
|
||||
## subquery被下降的情况
|
||||
select /*+ BEGIN_OUTLINE_DATA INDEX(@"SEL$1" "opt.t4"@"SEL$1" "idx_t4_c2_c3") INDEX(@"SEL$2" "opt.t1"@"SEL$2" "idx_t1_c2") END_OUTLINE_DATA */* from t4 where c1 in (select max(c1) from t1);
|
||||
select * from t4 where c1 in (select max(c1) from t1);
|
||||
select /*+ BEGIN_OUTLINE_DATA USE_NL(@"SEL$3" "opt.t2"@"SEL$3") LEADING(@"SEL$3" "opt.t1"@"SEL$3" "opt.t2"@"SEL$3") END_OUTLINE_DATA */* from t1 where c1 in (select * from (select max(t1.c1) from t1, t2) as tt);
|
||||
## 由于bug,暂时注释
|
||||
## select /*+ BEGIN_OUTLINE_DATA USE_NL(@"SEL$3" "opt.t2"@"SEL$3") LEADING(@"SEL$3" "opt.t1"@"SEL$3" "opt.t2"@"SEL$3") END_OUTLINE_DATA */* from t1 where c1 in (select * from (select max(t1.c1) from t1, t2) as tt);
|
||||
## select * from t1 where c1 in (select * from (select max(t1.c1) from t1, t2) as tt);
|
||||
|
||||
|
||||
|
||||
#测试指定hint的结果是否正确
|
||||
select /*+index(t4 idx_t4_c3)*/ * from t4 where c1 = 1;
|
||||
select /*+ BEGIN_OUTLINE_DATA INDEX(@"SEL$1" "opt.t4"@"SEL$1" "idx_t4_c3") END_OUTLINE_DATA */ * from t4 where c1 = 1;
|
||||
select /*+full(t4)*/ * from t4 where c2 = 1;
|
||||
select /*+ BEGIN_OUTLINE_DATA FULL(@"SEL$1" "opt.t4"@"SEL$1") END_OUTLINE_DATA */ * from t4 where c2 = 1;
|
||||
|
||||
|
||||
#test for join_hint
|
||||
select * from t1,t2;
|
||||
select * from t1,t2 where t1.c1=t2.c1;
|
||||
select * from t1,(select count(*) from t2) as tt;
|
||||
@ -30,7 +33,7 @@ select * from t1,t2 where (t1.c1 + t2.c1) in (select t9.c1 from t9, t10);
|
||||
select * from t1,t2 where (t1.c1 + t2.c1) in (select max(t9.c1) from t9, t10);
|
||||
select * from t8, (select count(*) from t1 where t1.c1 > any (select t2.c1 from t2)) as tt;
|
||||
|
||||
|
||||
#测试join的outline是否正确
|
||||
select /*+ BEGIN_OUTLINE_DATA USE_MERGE(@"SEL$1" "opt.t2"@"SEL$1") LEADING(@"SEL$1" "opt.t1"@"SEL$1" "opt.t2"@"SEL$1") FULL(@"SEL$1" "opt.t1"@"SEL$1") FULL(@"SEL$1" "opt.t2"@"SEL$1") END_OUTLINE_DATA */* from t1,t2 where t1.c1=t2.c1;
|
||||
select /*+ BEGIN_OUTLINE_DATA USE_MERGE(@"SEL$1" "opt.t1"@"SEL$1") LEADING(@"SEL$1" "opt.t2"@"SEL$1" "opt.t1"@"SEL$1") FULL(@"SEL$1" "opt.t2"@"SEL$1") FULL(@"SEL$1" "opt.t1"@"SEL$1") END_OUTLINE_DATA */* from t1,t2 where t1.c1=t2.c1;
|
||||
select /*+ BEGIN_OUTLINE_DATA USE_NL(@"SEL$1" "opt.tt2"@"SEL$1") LEADING(@"SEL$1" "opt.tt1"@"SEL$1" "opt.tt2"@"SEL$1") FULL(@"SEL$1" "opt.tt1"@"SEL$1") FULL(@"SEL$1" "opt.tt2"@"SEL$1") END_OUTLINE_DATA */* from t1 as tt1,t2 as tt2 where tt1.c1=tt2.c1;
|
||||
@ -55,7 +58,7 @@ select * from t1,(select /*+use_plan_cache(none)*/ count(*) from t2) as tt;
|
||||
select * from t1,(select /*+use_plan_cache(default)*/ count(*) from t2) as tt;
|
||||
select * from t1,(select /*+use_plan_cache(nothing)*/ count(*) from t2) as tt;
|
||||
|
||||
|
||||
#测试指定hint的结果是否正确
|
||||
select /*+ BEGIN_OUTLINE_DATA FULL(@"SEL$1" "t1"@"SEL$1") READ_CONSISTENCY("WEAK") HOTSPOT TOPK(1 100) QUERY_TIMEOUT(100) FROZEN_VERSION(1) USE_PLAN_CACHE("EXACT") NO_REWRITE TRACE_LOG LOG_LEVEL('info') END_OUTLINE_DATA */* from t1;
|
||||
#test for group
|
||||
select max(c1) from t1 group by c1;
|
||||
@ -73,32 +76,32 @@ select /*+no_use_late_materialization index(t_normal_idx idx)*/* from t_normal_i
|
||||
|
||||
##### test for subquery #####
|
||||
|
||||
|
||||
## 根节点是SPF的情况
|
||||
select * from t1 where t1.c1 > (select c1 from t2);
|
||||
select * from t1,t2 where (t1.c1 + t2.c1) > (select c1 from t3);
|
||||
select * from t1,t2 where (t1.c1 + t2.c1) > (select t3.c1 from t3, t4);
|
||||
|
||||
|
||||
## SPF在JOIN节点下面的情况
|
||||
select * from t1,t2 where t1.c1 > (select c1 from t2);
|
||||
select /*+use_nl(t2) leading(t1 t2)*/ * from t1,t2 where t2.c1 > (select 1);
|
||||
select /*+use_nl(t2) leading(t1 t2)*/ * from t1,t2 where t1.c1 > (select 1);
|
||||
|
||||
### 测试hint对spf的有效性
|
||||
select /*+use_nl(t1) leading(t2 t1)*/ * from t1,t2 where t2.c1 > (select 1);
|
||||
select /*+use_nl(t1) leading(t2 t1)*/ * from t1,t2 where t1.c1 > (select 1);
|
||||
|
||||
|
||||
### 左枝是spf,且spf左枝是join
|
||||
select * from t1,t2,t3 where (t2.c1 + t1.c1) > (select 1);
|
||||
|
||||
### 左枝是spf,且spf左枝和右枝都是join
|
||||
select * from t1,t2,t3 where (t2.c1 + t1.c1) > (select t4.c1 from t4, t5);
|
||||
|
||||
|
||||
## 多个subquey
|
||||
select 1 from t1 inner join t1 t2 using(c1) where t1.c1 < (select t3.c1 from t3) and t1.c1 > (select t4.c1 from t4);
|
||||
select 1 from t1 inner join t1 t2 using(c1) where t1.c1 < (select t3.c1 from t3) order by (select t4.c1 from t4);
|
||||
|
||||
|
||||
## subquery中含有join
|
||||
select 1 from t1 inner join t1 t2 using(c1) where t1.c1 < (select t4.c1 from t3, t4);
|
||||
|
||||
|
||||
## test qb_name, explain outline中不应该显示qb_name
|
||||
select /*+qb_name(select_1)*/* from t4;
|
||||
select /*+qb_name(select_1) qb_name(select_2)*/* from t4;
|
||||
|
||||
|
Reference in New Issue
Block a user