sql语句中加入limit 导致查询结果出不来,去掉就可以

【 使用环境 】生产环境
【 OB or 其他组件 】
【 使用版本 】4.2.1
【问题描述】请问,sql语句中加入limit 导致查询结果出不来,去掉就可以。limit这么大影响?
sql:

	SELECT * from (
	
	SELECT
		dt0.diagnostician_type_id ,
		dt0.diagnostician_type_name ,
		dtg.tician_tag_name 标签,
		o.diag_obj_id 对象ID,
		o.diag_obj_name 名称,
		o.show_seq 对象显示顺序,
		r.resource_id 资源ID,
		r.resource_name 资源名称,
		r.resource_show_seq 资源显示顺序
	FROM
		dw_actual_answer_naire_question a
		JOIN dw_diag_Obj o ON a.diag_obj_id = o.diag_obj_id
		JOIN v_diag_obj_resource r ON o.diag_obj_id = r.diag_obj_id
		JOIN dw_diagnostician d ON a.diagnostician_id = d.diagnostician_id
		JOIN dw_tician_type dt ON d.diagnostician_id = dt.diagnostician_id
		JOIN dw_diagnostician_type dt0 ON dt.diagnostician_type_id = dt0.diagnostician_type_id
		JOIN dw_tician_tag dtg ON d.diagnostician_id = dtg.diagnostician_id
		JOIN dw_diag_obj_rpt_tag rtag ON rtag.diag_obj_id = o.diag_obj_id 
		AND rtag.rpt_tag = dtg.tician_tag_name
		JOIN dw_diag_obj_rpt_tag rtag1 ON rtag1.diag_obj_id = o.diag_obj_id 
WHERE
		a.school_code IN ( 'fsswgy' ) 
		AND a.school_term_id IN ( '2411' ) 
		AND o.diag_obj_type_id IN ( 'ZY', 'ZYFL', 'ZYX' ) 
		AND rtag1.rpt_tag IN ( '全部' ) 
		AND dt0.diagnostician_type_id IN ( 'XS' ) 
		
GROUP BY
		dt0.diagnostician_type_id,
		dtg.tician_tag_name,
		o.diag_obj_id,
		o.diag_obj_name,
		o.show_seq 
				
)		
LIMIT 11

解释:

=====================================================================================================
|ID|OPERATOR                                  |NAME                           |EST.ROWS|EST.TIME(us)|
-----------------------------------------------------------------------------------------------------
|0 |LIMIT                                     |                               |11      |2023547     |
|1 |└─HASH GROUP BY                           |                               |11      |2023547     |
|2 |  └─NESTED-LOOP JOIN CARTESIAN            |                               |401     |2023505     |
|3 |    ├─PX COORDINATOR                      |                               |1       |6           |
|4 |    │ └─EXCHANGE OUT DISTR                |:EX10000                       |1       |5           |
|5 |    │   └─TABLE GET                       |dt0                            |1       |5           |
|6 |    └─NESTED-LOOP JOIN                    |                               |401     |2023489     |
|7 |      ├─NESTED-LOOP JOIN                  |                               |360     |2016934     |
|8 |      │ ├─HASH JOIN                       |                               |343     |2010684     |
|9 |      │ │ ├─TABLE RANGE SCAN              |a(diag_obj_id_diagnostician_id)|890075  |129033      |
|10|      │ │ └─NESTED-LOOP JOIN              |                               |2020103 |368679      |
|11|      │ │   ├─HASH JOIN                   |                               |8773    |93002       |
|12|      │ │   │ ├─TABLE FULL SCAN           |r                              |5751    |389         |
|13|      │ │   │ └─MERGE JOIN                |                               |8202    |87103       |
|14|      │ │   │   ├─MERGE JOIN              |                               |5998    |48050       |
|15|      │ │   │   │ ├─SORT                  |                               |5049    |19946       |
|16|      │ │   │   │ │ └─TABLE RANGE SCAN    |o(t_d)                         |5049    |16461       |
|17|      │ │   │   │ └─TABLE RANGE SCAN      |rtag1(tag_obj_1)               |753383  |24758       |
|18|      │ │   │   └─TABLE FULL SCAN         |rtag                           |1060072 |34779       |
|19|      │ │   └─DISTRIBUTED TABLE RANGE SCAN|dtg(tician_tag_name)           |231     |25          |
|20|      │ └─DISTRIBUTED TABLE RANGE SCAN    |d(diagnostician_id)            |1       |18          |
|21|      └─DISTRIBUTED TABLE RANGE SCAN      |dt(d_t)                        |1       |18          |
=====================================================================================================
Outputs & filters:
-------------------------------------
  0 - output([dt0.diagnostician_type_id], [dt0.diagnostician_type_name], [dtg.tician_tag_name], [o.diag_obj_id], [o.diag_obj_name], [o.show_seq], [r.resource_id],
       [r.resource_name], [r.resource_show_seq]), filter(nil), rowset=256
      limit(11), offset(nil)
  1 - output([dt0.diagnostician_type_id], [dt0.diagnostician_type_name], [dtg.tician_tag_name], [o.diag_obj_id], [o.diag_obj_name], [o.show_seq], [r.resource_id],
       [r.resource_name], [r.resource_show_seq]), filter(nil), rowset=256
      group([o.diag_obj_id], [dtg.tician_tag_name]), agg_func(nil)
  2 - output([dt0.diagnostician_type_id], [dt0.diagnostician_type_name], [dtg.tician_tag_name], [o.diag_obj_id], [o.diag_obj_name], [o.show_seq], [r.resource_id],
       [r.resource_name], [r.resource_show_seq]), filter(nil), rowset=256
      conds(nil), nl_params_(nil), use_batch=false
  3 - output([dt0.diagnostician_type_id], [dt0.diagnostician_type_name]), filter(nil), rowset=256
  4 - output([dt0.diagnostician_type_id], [dt0.diagnostician_type_name]), filter(nil), rowset=256
      is_single, dop=1
  5 - output([dt0.diagnostician_type_id], [dt0.diagnostician_type_name]), filter(nil), rowset=256
      access([dt0.diagnostician_type_id], [dt0.diagnostician_type_name]), partitions(p0)
      is_index_back=false, is_global_index=false, 
      range_key([dt0.diagnostician_type_id]), range[XS ; XS], 
      range_cond([dt0.diagnostician_type_id = 'XS'])
  6 - output([dtg.tician_tag_name], [o.diag_obj_id], [o.diag_obj_name], [o.show_seq], [r.resource_id], [r.resource_name], [r.resource_show_seq]), filter(nil), rowset=256
      conds(nil), nl_params_([a.diagnostician_id(:6)]), use_batch=true
  7 - output([dtg.tician_tag_name], [o.diag_obj_id], [o.diag_obj_name], [o.show_seq], [r.resource_id], [r.resource_name], [r.resource_show_seq], [a.diagnostician_id]), filter(nil), rowset=256
      conds(nil), nl_params_([a.diagnostician_id(:4)]), use_batch=true
  8 - output([dtg.tician_tag_name], [o.diag_obj_id], [o.diag_obj_name], [o.show_seq], [r.resource_id], [r.resource_name], [r.resource_show_seq], [a.diagnostician_id]), filter(nil), rowset=256
      equal_conds([a.diag_obj_id = o.diag_obj_id], [dtg.diagnostician_id = a.diagnostician_id]), other_conds(nil)
  9 - output([a.diag_obj_id], [a.diagnostician_id]), filter(nil), rowset=256
      access([a.diag_obj_id], [a.diagnostician_id]), partitions(p63)
      is_index_back=false, is_global_index=false, 
      range_key([a.school_code], [a.school_term_id], [a.diag_obj_id], [a.diagnostician_id], [a.ID]), range(fsswgyxx,2411,MIN,MIN,MIN ; fsswgyxx,2411,MAX,
      MAX,MAX), 
      range_cond([a.school_code = 'fsswgyxx'], [cast(a.school_term_id, DECIMAL(11, 0)) = cast('2411', DECIMAL(1, -1))])
 10 - output([dtg.tician_tag_name], [o.diag_obj_id], [o.diag_obj_name], [o.show_seq], [r.resource_id], [r.resource_name], [r.resource_show_seq], [dtg.diagnostician_id]), filter(nil), rowset=256
      conds(nil), nl_params_([rtag.rpt_tag(:31)]), use_batch=true
 11 - output([o.diag_obj_id], [o.diag_obj_name], [o.show_seq], [r.resource_id], [r.resource_name], [r.resource_show_seq], [rtag.rpt_tag]), filter(nil), rowset=256
      equal_conds([o.diag_obj_id = r.diag_obj_id]), other_conds(nil)
 12 - output([r.diag_obj_id], [r.resource_id], [r.resource_name], [r.resource_show_seq]), filter(nil), rowset=256
      access([r.diag_obj_id], [r.resource_id], [r.resource_name], [r.resource_show_seq]), partitions(p0)
      is_index_back=false, is_global_index=false, 
      range_key([r.__pk_increment]), range(MIN ; MAX)always true
 13 - output([o.diag_obj_id], [o.diag_obj_name], [o.show_seq], [rtag.rpt_tag]), filter(nil), rowset=256
      equal_conds([rtag.diag_obj_id = o.diag_obj_id]), other_conds(nil)
      merge_directions([ASC])
 14 - output([o.diag_obj_id], [o.diag_obj_name], [o.show_seq]), filter(nil), rowset=256
      equal_conds([rtag1.diag_obj_id = o.diag_obj_id]), other_conds(nil)
      merge_directions([ASC])
 15 - output([o.diag_obj_id], [o.diag_obj_name], [o.show_seq]), filter(nil), rowset=256
      sort_keys([o.diag_obj_id, ASC])
 16 - output([o.diag_obj_id], [o.diag_obj_name], [o.show_seq]), filter(nil), rowset=256
      access([o.diag_obj_id], [o.diag_obj_name], [o.show_seq]), partitions(p0)
      is_index_back=true, is_global_index=false, 
      range_key([o.diag_obj_type_id], [o.diag_obj_id]), range(ZY,MIN ; ZY,MAX), (ZYFL,MIN ; ZYFL,MAX), (ZYX,MIN ; ZYX,MAX), 
      range_cond([o.diag_obj_type_id IN ('ZY', 'ZYFL', 'ZYX')])
 17 - output([rtag1.diag_obj_id]), filter(nil), rowset=256
      access([rtag1.diag_obj_id]), partitions(p0)
      is_index_back=false, is_global_index=false, 
      range_key([rtag1.rpt_tag], [rtag1.diag_obj_id]), range(全部,MIN ; 全部,MAX), 
      range_cond([rtag1.rpt_tag = '全部'])
 18 - output([rtag.diag_obj_id], [rtag.rpt_tag]), filter(nil), rowset=256
      access([rtag.diag_obj_id], [rtag.rpt_tag]), partitions(p0)
      is_index_back=false, is_global_index=false, 
      range_key([rtag.diag_obj_id], [rtag.rpt_tag]), range(MIN,MIN ; MAX,MAX)always true
 19 - output([dtg.diagnostician_id], [dtg.tician_tag_name]), filter(nil), rowset=256
      access([GROUP_ID], [dtg.diagnostician_id], [dtg.tician_tag_name]), partitions(p0)
      is_index_back=false, is_global_index=false, 
      range_key([dtg.tician_tag_name], [dtg.school_code], [dtg.school_term_id], [dtg.diagnostician_id], [dtg.school_seq], [dtg.tician_tag]), range(MIN ; 
      MAX), 
      range_cond([:31 = dtg.tician_tag_name])
 20 - output(nil), filter(nil), rowset=256
      access([GROUP_ID]), partitions(p0)
      is_index_back=false, is_global_index=false, 
      range_key([d.diagnostician_id], [d.shadow_pk_0], [d.shadow_pk_1], [d.shadow_pk_2], [d.shadow_pk_3]), range(MIN ; MAX), 
      range_cond([:4 = d.diagnostician_id])
 21 - output(nil), filter(nil), rowset=256
      access([GROUP_ID]), partitions(p0)
      is_index_back=false, is_global_index=false, 
      range_key([dt.diagnostician_type_id], [dt.diagnostician_id], [dt.school_code], [dt.school_term_id], [dt.school_seq]), range(MIN ; MAX), 
      range_cond([dt.diagnostician_type_id = 'XS'], [dt.diagnostician_id = :6])
1 个赞

出不来是指报错还是时间长,时间长是多久,另外需要提供explain extended计划

没有报错,执行20分钟还在执行。不加limit执行20秒就查询出结果了。

explain extended计划:

=====================================================================================================
|ID|OPERATOR                                  |NAME                           |EST.ROWS|EST.TIME(us)|
-----------------------------------------------------------------------------------------------------
|0 |LIMIT                                     |                               |401     |2023757     |
|1 |└─HASH GROUP BY                           |                               |401     |2023756     |
|2 |  └─NESTED-LOOP JOIN CARTESIAN            |                               |401     |2023505     |
|3 |    ├─PX COORDINATOR                      |                               |1       |6           |
|4 |    │ └─EXCHANGE OUT DISTR                |:EX10000                       |1       |5           |
|5 |    │   └─TABLE GET                       |dt0                            |1       |5           |
|6 |    └─NESTED-LOOP JOIN                    |                               |401     |2023489     |
|7 |      ├─NESTED-LOOP JOIN                  |                               |360     |2016934     |
|8 |      │ ├─HASH JOIN                       |                               |343     |2010684     |
|9 |      │ │ ├─TABLE RANGE SCAN              |a(diag_obj_id_diagnostician_id)|890075  |129033      |
|10|      │ │ └─NESTED-LOOP JOIN              |                               |2020103 |368679      |
|11|      │ │   ├─HASH JOIN                   |                               |8773    |93002       |
|12|      │ │   │ ├─TABLE FULL SCAN           |r                              |5751    |389         |
|13|      │ │   │ └─MERGE JOIN                |                               |8202    |87103       |
|14|      │ │   │   ├─MERGE JOIN              |                               |5998    |48050       |
|15|      │ │   │   │ ├─SORT                  |                               |5049    |19946       |
|16|      │ │   │   │ │ └─TABLE RANGE SCAN    |o(t_d)                         |5049    |16461       |
|17|      │ │   │   │ └─TABLE RANGE SCAN      |rtag1(tag_obj_1)               |753383  |24758       |
|18|      │ │   │   └─TABLE FULL SCAN         |rtag                           |1060072 |34779       |
|19|      │ │   └─DISTRIBUTED TABLE RANGE SCAN|dtg(tician_tag_name)           |231     |25          |
|20|      │ └─DISTRIBUTED TABLE RANGE SCAN    |d(diagnostician_id)            |1       |18          |
|21|      └─DISTRIBUTED TABLE RANGE SCAN      |dt(d_t)                        |1       |18          |
=====================================================================================================
Outputs & filters:
-------------------------------------
  0 - output([dt0.diagnostician_type_id(0x7fc8f8c3acf0)], [dt0.diagnostician_type_name(0x7fc8f8c4c650)], [dtg.tician_tag_name(0x7fc8f8c3eeb0)], [o.diag_obj_id(0x7fc8f8c31120)],
       [o.diag_obj_name(0x7fc8f8c4d290)], [o.show_seq(0x7fc8f8c4d890)], [r.resource_id(0x7fc8f8c4de90)], [r.resource_name(0x7fc8f8c4e490)], [r.resource_show_seq(0x7fc8f8c4ea90)]), filter(nil), rowset=256
      limit(20000001), offset(nil)
  1 - output([dt0.diagnostician_type_id(0x7fc8f8c3acf0)], [dt0.diagnostician_type_name(0x7fc8f8c4c650)], [dtg.tician_tag_name(0x7fc8f8c3eeb0)], [o.diag_obj_id(0x7fc8f8c31120)],
       [o.diag_obj_name(0x7fc8f8c4d290)], [o.show_seq(0x7fc8f8c4d890)], [r.resource_id(0x7fc8f8c4de90)], [r.resource_name(0x7fc8f8c4e490)], [r.resource_show_seq(0x7fc8f8c4ea90)]), filter(nil), rowset=256
      group([o.diag_obj_id(0x7fc8f8c31120)], [dtg.tician_tag_name(0x7fc8f8c3eeb0)]), agg_func(nil)
  2 - output([dt0.diagnostician_type_id(0x7fc8f8c3acf0)], [dt0.diagnostician_type_name(0x7fc8f8c4c650)], [dtg.tician_tag_name(0x7fc8f8c3eeb0)], [o.diag_obj_id(0x7fc8f8c31120)],
       [o.diag_obj_name(0x7fc8f8c4d290)], [o.show_seq(0x7fc8f8c4d890)], [r.resource_id(0x7fc8f8c4de90)], [r.resource_name(0x7fc8f8c4e490)], [r.resource_show_seq(0x7fc8f8c4ea90)]), filter(nil), rowset=256
      conds(nil), nl_params_(nil), use_batch=false
  3 - output([dt0.diagnostician_type_id(0x7fc8f8c3acf0)], [dt0.diagnostician_type_name(0x7fc8f8c4c650)]), filter(nil), rowset=256
  4 - output([dt0.diagnostician_type_id(0x7fc8f8c3acf0)], [dt0.diagnostician_type_name(0x7fc8f8c4c650)]), filter(nil), rowset=256
      is_single, dop=1
  5 - output([dt0.diagnostician_type_id(0x7fc8f8c3acf0)], [dt0.diagnostician_type_name(0x7fc8f8c4c650)]), filter(nil), rowset=256
      access([dt0.diagnostician_type_id(0x7fc8f8c3acf0)], [dt0.diagnostician_type_name(0x7fc8f8c4c650)]), partitions(p0)
      is_index_back=false, is_global_index=false, 
      range_key([dt0.diagnostician_type_id(0x7fc8f8c3acf0)]), range[XS ; XS], 
      range_cond([dt0.diagnostician_type_id(0x7fc8f8c3acf0) = 'XS'(0x7fc8f8c4a9b0)])
  6 - output([dtg.tician_tag_name(0x7fc8f8c3eeb0)], [o.diag_obj_id(0x7fc8f8c31120)], [o.diag_obj_name(0x7fc8f8c4d290)], [o.show_seq(0x7fc8f8c4d890)], [r.resource_id(0x7fc8f8c4de90)],
       [r.resource_name(0x7fc8f8c4e490)], [r.resource_show_seq(0x7fc8f8c4ea90)]), filter(nil), rowset=256
      conds(nil), nl_params_([a.diagnostician_id(0x7fc8f8c35c20)(:6)]), use_batch=true
  7 - output([dtg.tician_tag_name(0x7fc8f8c3eeb0)], [o.diag_obj_id(0x7fc8f8c31120)], [o.diag_obj_name(0x7fc8f8c4d290)], [o.show_seq(0x7fc8f8c4d890)], [r.resource_id(0x7fc8f8c4de90)],
       [r.resource_name(0x7fc8f8c4e490)], [r.resource_show_seq(0x7fc8f8c4ea90)], [a.diagnostician_id(0x7fc8f8c35c20)]), filter(nil), rowset=256
      conds(nil), nl_params_([a.diagnostician_id(0x7fc8f8c35c20)(:4)]), use_batch=true
  8 - output([dtg.tician_tag_name(0x7fc8f8c3eeb0)], [o.diag_obj_id(0x7fc8f8c31120)], [o.diag_obj_name(0x7fc8f8c4d290)], [o.show_seq(0x7fc8f8c4d890)], [r.resource_id(0x7fc8f8c4de90)],
       [r.resource_name(0x7fc8f8c4e490)], [r.resource_show_seq(0x7fc8f8c4ea90)], [a.diagnostician_id(0x7fc8f8c35c20)]), filter(nil), rowset=256
      equal_conds([a.diag_obj_id(0x7fc8f8c30e30) = o.diag_obj_id(0x7fc8f8c31120)(0x7fc8f8c306e0)], [dtg.diagnostician_id(0x7fc8f8c3c2e0) = a.diagnostician_id(0x7fc8f8c35c20)(0x7fc8f8cfa210)]),
       other_conds(nil)
  9 - output([a.diag_obj_id(0x7fc8f8c30e30)], [a.diagnostician_id(0x7fc8f8c35c20)]), filter(nil), rowset=256
      access([a.diag_obj_id(0x7fc8f8c30e30)], [a.diagnostician_id(0x7fc8f8c35c20)]), partitions(p63)
      is_index_back=false, is_global_index=false, 
      range_key([a.school_code(0x7fc8f8c2fac0)], [a.school_term_id(0x7fc8f8c43490)], [a.diag_obj_id(0x7fc8f8c30e30)], [a.diagnostician_id(0x7fc8f8c35c20)],
       [a.ID(0x7fc8f8c514a0)]), range(fsswgyxx,2411,MIN,MIN,MIN ; fsswgyxx,2411,MAX,MAX,MAX), 
      range_cond([a.school_code(0x7fc8f8c2fac0) = 'fsswgyxx'(0x7fc8f8c40a40)], [cast(a.school_term_id(0x7fc8f8c43490), DECIMAL(11, 0))(0x7fc8f8c43a00) = 
      cast('2411', DECIMAL(1, -1))(0x7fc8f8c44550)(0x7fc8f8c420c0)])
 10 - output([dtg.tician_tag_name(0x7fc8f8c3eeb0)], [o.diag_obj_id(0x7fc8f8c31120)], [o.diag_obj_name(0x7fc8f8c4d290)], [o.show_seq(0x7fc8f8c4d890)], [r.resource_id(0x7fc8f8c4de90)],
       [r.resource_name(0x7fc8f8c4e490)], [r.resource_show_seq(0x7fc8f8c4ea90)], [dtg.diagnostician_id(0x7fc8f8c3c2e0)]), filter(nil), rowset=256
      conds(nil), nl_params_([rtag.rpt_tag(0x7fc8f8c3ebc0)(:31)]), use_batch=true
 11 - output([o.diag_obj_id(0x7fc8f8c31120)], [o.diag_obj_name(0x7fc8f8c4d290)], [o.show_seq(0x7fc8f8c4d890)], [r.resource_id(0x7fc8f8c4de90)], [r.resource_name(0x7fc8f8c4e490)],
       [r.resource_show_seq(0x7fc8f8c4ea90)], [rtag.rpt_tag(0x7fc8f8c3ebc0)]), filter(nil), rowset=256
      equal_conds([o.diag_obj_id(0x7fc8f8c31120) = r.diag_obj_id(0x7fc8f8c34630)(0x7fc8f8c33ed0)]), other_conds(nil)
 12 - output([r.diag_obj_id(0x7fc8f8c34630)], [r.resource_id(0x7fc8f8c4de90)], [r.resource_name(0x7fc8f8c4e490)], [r.resource_show_seq(0x7fc8f8c4ea90)]), filter(nil), rowset=256
      access([r.diag_obj_id(0x7fc8f8c34630)], [r.resource_id(0x7fc8f8c4de90)], [r.resource_name(0x7fc8f8c4e490)], [r.resource_show_seq(0x7fc8f8c4ea90)]), partitions(p0)
      is_index_back=false, is_global_index=false, 
      range_key([r.__pk_increment(0x7fc8f8c51780)]), range(MIN ; MAX)always true
 13 - output([o.diag_obj_id(0x7fc8f8c31120)], [o.diag_obj_name(0x7fc8f8c4d290)], [o.show_seq(0x7fc8f8c4d890)], [rtag.rpt_tag(0x7fc8f8c3ebc0)]), filter(nil), rowset=256
      equal_conds([rtag.diag_obj_id(0x7fc8f8c3d8d0) = o.diag_obj_id(0x7fc8f8c31120)(0x7fc8f8c3d180)]), other_conds(nil)
      merge_directions([ASC])
 14 - output([o.diag_obj_id(0x7fc8f8c31120)], [o.diag_obj_name(0x7fc8f8c4d290)], [o.show_seq(0x7fc8f8c4d890)]), filter(nil), rowset=256
      equal_conds([rtag1.diag_obj_id(0x7fc8f8c404a0) = o.diag_obj_id(0x7fc8f8c31120)(0x7fc8f8c3fd50)]), other_conds(nil)
      merge_directions([ASC])
 15 - output([o.diag_obj_id(0x7fc8f8c31120)], [o.diag_obj_name(0x7fc8f8c4d290)], [o.show_seq(0x7fc8f8c4d890)]), filter(nil), rowset=256
      sort_keys([o.diag_obj_id(0x7fc8f8c31120), ASC])
 16 - output([o.diag_obj_id(0x7fc8f8c31120)], [o.diag_obj_name(0x7fc8f8c4d290)], [o.show_seq(0x7fc8f8c4d890)]), filter(nil), rowset=256
      access([o.diag_obj_id(0x7fc8f8c31120)], [o.diag_obj_name(0x7fc8f8c4d290)], [o.show_seq(0x7fc8f8c4d890)]), partitions(p0)
      is_index_back=true, is_global_index=false, 
      range_key([o.diag_obj_type_id(0x7fc8f8c469f0)], [o.diag_obj_id(0x7fc8f8c31120)]), range(ZY,MIN ; ZY,MAX), (ZYFL,MIN ; ZYFL,MAX), (ZYX,MIN ; ZYX,MAX),
       
      range_cond([o.diag_obj_type_id(0x7fc8f8c469f0) IN ('ZY', 'ZYFL', 'ZYX')(0x7fc8f8c68690)(0x7fc8f8c450c0)])
 17 - output([rtag1.diag_obj_id(0x7fc8f8c404a0)]), filter(nil), rowset=256
      access([rtag1.diag_obj_id(0x7fc8f8c404a0)]), partitions(p0)
      is_index_back=false, is_global_index=false, 
      range_key([rtag1.rpt_tag(0x7fc8f8c48510)], [rtag1.diag_obj_id(0x7fc8f8c404a0)]), range(全部,MIN ; 全部,MAX), 
      range_cond([rtag1.rpt_tag(0x7fc8f8c48510) = '全部'(0x7fc8f8c47140)])
 18 - output([rtag.diag_obj_id(0x7fc8f8c3d8d0)], [rtag.rpt_tag(0x7fc8f8c3ebc0)]), filter(nil), rowset=256
      access([rtag.diag_obj_id(0x7fc8f8c3d8d0)], [rtag.rpt_tag(0x7fc8f8c3ebc0)]), partitions(p0)
      is_index_back=false, is_global_index=false, 
      range_key([rtag.diag_obj_id(0x7fc8f8c3d8d0)], [rtag.rpt_tag(0x7fc8f8c3ebc0)]), range(MIN,MIN ; MAX,MAX)always true
 19 - output([dtg.diagnostician_id(0x7fc8f8c3c2e0)], [dtg.tician_tag_name(0x7fc8f8c3eeb0)]), filter(nil), rowset=256
      access([GROUP_ID(0x7fcf85661960)], [dtg.diagnostician_id(0x7fc8f8c3c2e0)], [dtg.tician_tag_name(0x7fc8f8c3eeb0)]), partitions(p0)
      is_index_back=false, is_global_index=false, 
      range_key([dtg.tician_tag_name(0x7fc8f8c3eeb0)], [dtg.school_code(0x7fc8f8c52ba0)], [dtg.school_term_id(0x7fc8f8c52e80)], [dtg.diagnostician_id(0x7fc8f8c3c2e0)],
       [dtg.school_seq(0x7fc8f8c53160)], [dtg.tician_tag(0x7fc8f8c53440)]), range(MIN ; MAX), 
      range_cond([:31 = dtg.tician_tag_name(0x7fc8f8c3eeb0)(0x7fc8e6a829c0)])
 20 - output(nil), filter(nil), rowset=256
      access([GROUP_ID(0x7fcf85661bb0)]), partitions(p0)
      is_index_back=false, is_global_index=false, 
      range_key([d.diagnostician_id(0x7fc8f8c35f10)], [d.shadow_pk_0(0x7fc8f8d7d840)], [d.shadow_pk_1(0x7fc8f8d7db20)], [d.shadow_pk_2(0x7fc8f8d7de00)],
       [d.shadow_pk_3(0x7fc8f8d7fff0)]), range(MIN ; MAX), 
      range_cond([:4 = d.diagnostician_id(0x7fc8f8c35f10)(0x7fcf8219b580)])
 21 - output(nil), filter(nil), rowset=256
      access([GROUP_ID(0x7fcf85661e00)]), partitions(p0)
      is_index_back=false, is_global_index=false, 
      range_key([dt.diagnostician_type_id(0x7fc8f8c3aa00)], [dt.diagnostician_id(0x7fc8f8c39410)], [dt.school_code(0x7fc8f8c52300)], [dt.school_term_id(0x7fc8f8c525e0)],
       [dt.school_seq(0x7fc8f8c528c0)]), range(MIN ; MAX), 
      range_cond([dt.diagnostician_type_id(0x7fc8f8c3aa00) = 'XS'(0x7fc8f8c65db0)], [dt.diagnostician_id(0x7fc8f8c39410) = :6(0x7fd01ac21190)])
Used Hint:
-------------------------------------
  /*+
      
  */
Qb name trace:
-------------------------------------
  stmt_id:0, stmt_type:T_EXPLAIN 
  stmt_id:1, SEL$1 > SEL$C6D21C0F > SEL$9E7FBB94
Outline Data: 
-------------------------------------
  /*+
      BEGIN_OUTLINE_DATA
      USE_HASH_AGGREGATION(@"SEL$9E7FBB94")
      LEADING(@"SEL$9E7FBB94" ("edu_dw"."dt0"@"SEL$1" ((("edu_dw"."a"@"SEL$1" (("edu_dw"."r"@"SEL$1" (("edu_dw"."o"@"SEL$1" "edu_dw"."rtag1"@"SEL$1") "edu_dw"."rtag"@"SEL$1")) "edu_dw"."dtg"@"SEL$1")) "edu_dw"."d"@"SEL$1") "edu_dw"."dt"@"SEL$1")))
      USE_NL(@"SEL$9E7FBB94" ("edu_dw"."rtag1"@"SEL$1" "edu_dw"."rtag"@"SEL$1" "edu_dw"."r"@"SEL$1" "edu_dw"."o"@"SEL$1" "edu_dw"."dtg"@"SEL$1" "edu_dw"."dt"@"SEL$1" "edu_dw"."d"@"SEL$1" "edu_dw"."a"@"SEL$1"))
      PQ_DISTRIBUTE(@"SEL$9E7FBB94" ("edu_dw"."rtag1"@"SEL$1" "edu_dw"."rtag"@"SEL$1" "edu_dw"."r"@"SEL$1" "edu_dw"."o"@"SEL$1" "edu_dw"."dtg"@"SEL$1" "edu_dw"."dt"@"SEL$1" "edu_dw"."d"@"SEL$1" "edu_dw"."a"@"SEL$1") LOCAL LOCAL)
      FULL(@"SEL$9E7FBB94" "dt0"@"SEL$1")
      USE_NL(@"SEL$9E7FBB94" "edu_dw"."dt"@"SEL$1")
      USE_NL(@"SEL$9E7FBB94" "edu_dw"."d"@"SEL$1")
      USE_HASH(@"SEL$9E7FBB94" ("edu_dw"."rtag1"@"SEL$1" "edu_dw"."rtag"@"SEL$1" "edu_dw"."r"@"SEL$1" "edu_dw"."o"@"SEL$1" "edu_dw"."dtg"@"SEL$1"))
      INDEX(@"SEL$9E7FBB94" "a"@"SEL$1" "diag_obj_id_diagnostician_id")
      USE_NL(@"SEL$9E7FBB94" "edu_dw"."dtg"@"SEL$1")
      USE_HASH(@"SEL$9E7FBB94" ("edu_dw"."rtag1"@"SEL$1" "edu_dw"."rtag"@"SEL$1" "edu_dw"."o"@"SEL$1"))
      FULL(@"SEL$9E7FBB94" "r"@"SEL$1")
      USE_MERGE(@"SEL$9E7FBB94" "edu_dw"."rtag"@"SEL$1")
      USE_MERGE(@"SEL$9E7FBB94" "edu_dw"."rtag1"@"SEL$1")
      INDEX(@"SEL$9E7FBB94" "o"@"SEL$1" "t_d")
      INDEX(@"SEL$9E7FBB94" "rtag1"@"SEL$1" "tag_obj_1")
      FULL(@"SEL$9E7FBB94" "rtag"@"SEL$1")
      INDEX(@"SEL$9E7FBB94" "dtg"@"SEL$1" "tician_tag_name")
      USE_DAS(@"SEL$9E7FBB94" "dtg"@"SEL$1")
      INDEX(@"SEL$9E7FBB94" "d"@"SEL$1" "diagnostician_id")
      USE_DAS(@"SEL$9E7FBB94" "d"@"SEL$1")
      INDEX(@"SEL$9E7FBB94" "dt"@"SEL$1" "d_t")
      USE_DAS(@"SEL$9E7FBB94" "dt"@"SEL$1")
      OUTER_TO_INNER(@"SEL$1")
      PRED_DEDUCE(@"SEL$C6D21C0F")
      OPTIMIZER_FEATURES_ENABLE('4.0.0.0')
      END_OUTLINE_DATA
  */
Optimization Info:
-------------------------------------
  dt0:
      table_rows:9
      physical_range_rows:1
      logical_range_rows:1
      index_back_rows:0
      output_rows:1
      table_dop:1
      dop_method:Table DOP
      avaiable_index_name:[diagnostician_type_id, dw_diagnostician_type]
      pruned_index_name:[diagnostician_type_id]
      stats version:1715177800396252
      dynamic sampling level:0
  a:
      table_rows:1166518
      physical_range_rows:2727708
      logical_range_rows:890075
      index_back_rows:0
      output_rows:890075
      table_dop:1
      dop_method:Table DOP
      avaiable_index_name:[naire_answer_rec_id, diag_obj_id_diagnostician_id, diag_obj_id_q_id, diag_obj_id, diagnostician_id, school_code, school_term_id, q_id, school_seq, idx_school_term_qid, answer, idx_schoolcode_termid_qid, dw_actual_answer_naire_question]
      pruned_index_name:[naire_answer_rec_id, diag_obj_id_q_id, diag_obj_id, school_code, school_term_id, q_id, school_seq, idx_school_term_qid, answer, idx_schoolcode_termid_qid, dw_actual_answer_naire_question]
      stats version:1715178531266868
      dynamic sampling level:0
  r:
      table_rows:5817
      physical_range_rows:6345
      logical_range_rows:5751
      index_back_rows:0
      output_rows:5751
      table_dop:1
      dop_method:Table DOP
      avaiable_index_name:[diag_obj_id, v_diag_obj_resource]
      stats version:1715176850282535
      dynamic sampling level:0
  o:
      table_rows:756608
      physical_range_rows:5131
      logical_range_rows:5049
      index_back_rows:5049
      output_rows:5049
      table_dop:1
      dop_method:Table DOP
      avaiable_index_name:[school_code, s_s_t_d, d_t, t_d, diag_obj_id, dw_diag_obj]
      pruned_index_name:[school_code, s_s_t_d, d_t, diag_obj_id]
      stats version:1715177851810419
      dynamic sampling level:0
  rtag1:
      table_rows:1054757
      physical_range_rows:758221
      logical_range_rows:753383
      index_back_rows:0
      output_rows:753383
      table_dop:1
      dop_method:Table DOP
      avaiable_index_name:[diag_obj_id, tag_obj, tag_obj_1, rpt_tag, dw_diag_obj_rpt_tag]
      pruned_index_name:[diag_obj_id, tag_obj, dw_diag_obj_rpt_tag]
      stats version:1715091401445868
      dynamic sampling level:0
  rtag:
      table_rows:1054757
      physical_range_rows:1065316
      logical_range_rows:1060072
      index_back_rows:0
      output_rows:1060072
      table_dop:1
      dop_method:Table DOP
      avaiable_index_name:[diag_obj_id, tag_obj, tag_obj_1, rpt_tag, dw_diag_obj_rpt_tag]
      stats version:1715091401445868
      dynamic sampling level:0
  dtg:
      table_rows:5017979
      physical_range_rows:230
      logical_range_rows:230
      index_back_rows:0
      output_rows:230
      table_dop:1
      dop_method:DAS DOP
      avaiable_index_name:[school_seq, diagnostician_id, tician_tag, school_code, school_term_id, tician_tag_name, diagnostician_tician_tag_name, dw_tician_tag]
      pruned_index_name:[school_seq, tician_tag, school_code, school_term_id, dw_tician_tag]
      stats version:1715176874327844
      dynamic sampling level:0
  d:
      table_rows:1679889
      physical_range_rows:1
      logical_range_rows:1
      index_back_rows:0
      output_rows:1
      table_dop:1
      dop_method:DAS DOP
      avaiable_index_name:[diagnostician_id, school_code, school_seq, school_term_id, school_code_2, idx_code, diagnostician_type_id, dw_diagnostician]
      pruned_index_name:[school_code, school_seq, school_term_id, school_code_2, idx_code, diagnostician_type_id, dw_diagnostician]
      stats version:1704291123472779
      dynamic sampling level:0
  dt:
      table_rows:2156505
      physical_range_rows:1
      logical_range_rows:1
      index_back_rows:0
      output_rows:1
      table_dop:1
      dop_method:DAS DOP
      avaiable_index_name:[school_seq, diagnostician_type_id, diagnostician_id, school_term_id, school_code, d_t, idx_d_id, dw_tician_type]
      pruned_index_name:[school_seq, diagnostician_type_id, school_term_id, school_code, idx_d_id, dw_tician_type]
      stats version:1715176861845681
      dynamic sampling level:0
  Plan Type:
      DISTRIBUTED
  Note:
      Degree of Parallelisim is 1 because of table property

有limit,执行时间:1489s;


这里这个值怎么这么大

另外把不加limit的explain 计划也发下吧,以及查询结果实际是多少行

结果不多,也就46条记录。下面是不加limit的explain 计划:

=================================================================================================
|ID|OPERATOR                              |NAME                           |EST.ROWS|EST.TIME(us)|
-------------------------------------------------------------------------------------------------
|0 |MERGE GROUP BY                        |                               |401     |4254929     |
|1 |└─PARTITION SORT                      |                               |401     |4254717     |
|2 |  └─NESTED-LOOP JOIN CARTESIAN        |                               |401     |4254481     |
|3 |    ├─PX COORDINATOR                  |                               |1       |6           |
|4 |    │ └─EXCHANGE OUT DISTR            |:EX10000                       |1       |5           |
|5 |    │   └─TABLE GET                   |dt0                            |1       |5           |
|6 |    └─NESTED-LOOP JOIN                |                               |401     |4254465     |
|7 |      ├─NESTED-LOOP JOIN              |                               |360     |4247911     |
|8 |      │ ├─HASH JOIN                   |                               |343     |4241660     |
|9 |      │ │ ├─MERGE JOIN                |                               |1546487 |319828      |
|10|      │ │ │ ├─MERGE JOIN              |                               |8773    |93023       |
|11|      │ │ │ │ ├─SORT                  |                               |5751    |4322        |
|12|      │ │ │ │ │ └─TABLE FULL SCAN     |r                              |5751    |389         |
|13|      │ │ │ │ └─MERGE JOIN            |                               |8202    |87103       |
|14|      │ │ │ │   ├─MERGE JOIN          |                               |5998    |48050       |
|15|      │ │ │ │   │ ├─SORT              |                               |5049    |19946       |
|16|      │ │ │ │   │ │ └─TABLE RANGE SCAN|o(t_d)                         |5049    |16461       |
|17|      │ │ │ │   │ └─TABLE RANGE SCAN  |rtag1(tag_obj_1)               |753383  |24758       |
|18|      │ │ │ │   └─TABLE FULL SCAN     |rtag                           |1060072 |34779       |
|19|      │ │ │ └─TABLE RANGE SCAN        |a(diag_obj_id_diagnostician_id)|890075  |129033      |
|20|      │ │ └─TABLE FULL SCAN           |dtg                            |5066761 |290314      |
|21|      │ └─DISTRIBUTED TABLE RANGE SCAN|d(diagnostician_id)            |1       |18          |
|22|      └─DISTRIBUTED TABLE RANGE SCAN  |dt(d_t)                        |1       |18          |
=================================================================================================
Outputs & filters:
-------------------------------------
  0 - output([dt0.diagnostician_type_id(0x7fd062e56420)], [dt0.diagnostician_type_name(0x7fd062e67d80)], [CASE WHEN 'XS' = 'XS'(0x7fd062e68e10) THEN 20 
      ELSE CASE WHEN 'XS' = 'JZG'(0x7fd062e6a530) THEN 30 ELSE CASE WHEN 'XS' = 'GL'(0x7fd062e6bc50) THEN 10 ELSE CASE WHEN 'XS' = 'JSGL'(0x7fd062e6d3a0) THEN 
      12 ELSE CASE WHEN 'XS' = 'JS'(0x7fd062e6eac0) THEN 11 ELSE CASE WHEN 'XS' = 'JZ'(0x7fd062e701e0) THEN 29 ELSE CASE WHEN 'XS' = 'ZY'(0x7fd062e71960) THEN 
      18 ELSE 99 END(0x7fd062e70b60) END(0x7fd062e6f440) END(0x7fd062e6dd20) END(0x7fd062e6c5d0) END(0x7fd062e6aeb0) END(0x7fd062e69790) END(0x7fd062e68070)],
       [dtg.tician_tag_name(0x7fd062e5a5e0)], [o.diag_obj_id(0x7fd062e4c850)], [o.diag_obj_name(0x7fd062e73c50)], [o.show_seq(0x7fd062e74250)], [r.resource_id(0x7fd062e74850)],
       [r.resource_name(0x7fd062e74e50)], [r.resource_show_seq(0x7fd062e75450)], [T_FUN_COUNT(distinct a.diagnostician_id(0x7fd062e51350))(0x7fd062e75740)]), filter(nil), rowset=256
      group([o.diag_obj_id(0x7fd062e4c850)], [dtg.tician_tag_name(0x7fd062e5a5e0)], [dtg.tician_tag_show_seq(0x7fd062e767e0)]), agg_func([T_FUN_COUNT(distinct 
      a.diagnostician_id(0x7fd062e51350))(0x7fd062e75740)])
  1 - output([o.diag_obj_id(0x7fd062e4c850)], [dtg.tician_tag_name(0x7fd062e5a5e0)], [dtg.tician_tag_show_seq(0x7fd062e767e0)], [dt0.diagnostician_type_id(0x7fd062e56420)],
       [dt0.diagnostician_type_name(0x7fd062e67d80)], [o.diag_obj_name(0x7fd062e73c50)], [o.show_seq(0x7fd062e74250)], [r.resource_id(0x7fd062e74850)], [r.resource_name(0x7fd062e74e50)],
       [r.resource_show_seq(0x7fd062e75450)], [a.diagnostician_id(0x7fd062e51350)]), filter(nil), rowset=256
      sort_keys([HASH(o.diag_obj_id(0x7fd062e4c850), dtg.tician_tag_name(0x7fd062e5a5e0), dtg.tician_tag_show_seq(0x7fd062e767e0))(0x7fce2e6d72d0), ASC],
       [o.diag_obj_id(0x7fd062e4c850), ASC], [dtg.tician_tag_name(0x7fd062e5a5e0), ASC], [dtg.tician_tag_show_seq(0x7fd062e767e0), ASC])
  2 - output([o.diag_obj_id(0x7fd062e4c850)], [dtg.tician_tag_name(0x7fd062e5a5e0)], [dtg.tician_tag_show_seq(0x7fd062e767e0)], [dt0.diagnostician_type_id(0x7fd062e56420)],
       [dt0.diagnostician_type_name(0x7fd062e67d80)], [o.diag_obj_name(0x7fd062e73c50)], [o.show_seq(0x7fd062e74250)], [r.resource_id(0x7fd062e74850)], [r.resource_name(0x7fd062e74e50)],
       [r.resource_show_seq(0x7fd062e75450)], [a.diagnostician_id(0x7fd062e51350)]), filter(nil), rowset=256
      conds(nil), nl_params_(nil), use_batch=false
  3 - output([dt0.diagnostician_type_id(0x7fd062e56420)], [dt0.diagnostician_type_name(0x7fd062e67d80)]), filter(nil), rowset=256
  4 - output([dt0.diagnostician_type_id(0x7fd062e56420)], [dt0.diagnostician_type_name(0x7fd062e67d80)]), filter(nil), rowset=256
      is_single, dop=1
  5 - output([dt0.diagnostician_type_id(0x7fd062e56420)], [dt0.diagnostician_type_name(0x7fd062e67d80)]), filter(nil), rowset=256
      access([dt0.diagnostician_type_id(0x7fd062e56420)], [dt0.diagnostician_type_name(0x7fd062e67d80)]), partitions(p0)
      is_index_back=false, is_global_index=false, 
      range_key([dt0.diagnostician_type_id(0x7fd062e56420)]), range[XS ; XS], 
      range_cond([dt0.diagnostician_type_id(0x7fd062e56420) = 'XS'(0x7fd062e660e0)])
  6 - output([o.diag_obj_id(0x7fd062e4c850)], [dtg.tician_tag_name(0x7fd062e5a5e0)], [dtg.tician_tag_show_seq(0x7fd062e767e0)], [o.diag_obj_name(0x7fd062e73c50)],
       [o.show_seq(0x7fd062e74250)], [r.resource_id(0x7fd062e74850)], [r.resource_name(0x7fd062e74e50)], [r.resource_show_seq(0x7fd062e75450)], [a.diagnostician_id(0x7fd062e51350)]), filter(nil), rowset=256
      conds(nil), nl_params_([a.diagnostician_id(0x7fd062e51350)(:6)]), use_batch=true
  7 - output([o.diag_obj_id(0x7fd062e4c850)], [dtg.tician_tag_name(0x7fd062e5a5e0)], [dtg.tician_tag_show_seq(0x7fd062e767e0)], [o.diag_obj_name(0x7fd062e73c50)],
       [o.show_seq(0x7fd062e74250)], [r.resource_id(0x7fd062e74850)], [r.resource_name(0x7fd062e74e50)], [r.resource_show_seq(0x7fd062e75450)], [a.diagnostician_id(0x7fd062e51350)]), filter(nil), rowset=256
      conds(nil), nl_params_([a.diagnostician_id(0x7fd062e51350)(:4)]), use_batch=true
  8 - output([o.diag_obj_id(0x7fd062e4c850)], [dtg.tician_tag_name(0x7fd062e5a5e0)], [dtg.tician_tag_show_seq(0x7fd062e767e0)], [o.diag_obj_name(0x7fd062e73c50)],
       [o.show_seq(0x7fd062e74250)], [r.resource_id(0x7fd062e74850)], [r.resource_name(0x7fd062e74e50)], [r.resource_show_seq(0x7fd062e75450)], [a.diagnostician_id(0x7fd062e51350)]), filter(nil), rowset=256
      equal_conds([rtag.rpt_tag(0x7fd062e5a2f0) = dtg.tician_tag_name(0x7fd062e5a5e0)(0x7fd062e59ba0)], [dtg.diagnostician_id(0x7fd062e57a10) = a.diagnostician_id(0x7fd062e51350)(0x7fd062f46630)]),
       other_conds(nil)
  9 - output([o.diag_obj_id(0x7fd062e4c850)], [o.diag_obj_name(0x7fd062e73c50)], [o.show_seq(0x7fd062e74250)], [r.resource_id(0x7fd062e74850)], [r.resource_name(0x7fd062e74e50)],
       [r.resource_show_seq(0x7fd062e75450)], [a.diagnostician_id(0x7fd062e51350)], [rtag.rpt_tag(0x7fd062e5a2f0)]), filter(nil), rowset=256
      equal_conds([a.diag_obj_id(0x7fd062e4c560) = o.diag_obj_id(0x7fd062e4c850)(0x7fd062e4be10)]), other_conds(nil)
      merge_directions([ASC])
 10 - output([o.diag_obj_id(0x7fd062e4c850)], [o.diag_obj_name(0x7fd062e73c50)], [o.show_seq(0x7fd062e74250)], [r.resource_id(0x7fd062e74850)], [r.resource_name(0x7fd062e74e50)],
       [r.resource_show_seq(0x7fd062e75450)], [rtag.rpt_tag(0x7fd062e5a2f0)]), filter(nil), rowset=256
      equal_conds([o.diag_obj_id(0x7fd062e4c850) = r.diag_obj_id(0x7fd062e4fd60)(0x7fd062e4f600)]), other_conds(nil)
      merge_directions([ASC])
 11 - output([r.resource_id(0x7fd062e74850)], [r.resource_name(0x7fd062e74e50)], [r.resource_show_seq(0x7fd062e75450)], [r.diag_obj_id(0x7fd062e4fd60)]), filter(nil), rowset=256
      sort_keys([r.diag_obj_id(0x7fd062e4fd60), ASC])
 12 - output([r.diag_obj_id(0x7fd062e4fd60)], [r.resource_id(0x7fd062e74850)], [r.resource_name(0x7fd062e74e50)], [r.resource_show_seq(0x7fd062e75450)]), filter(nil), rowset=256
      access([r.diag_obj_id(0x7fd062e4fd60)], [r.resource_id(0x7fd062e74850)], [r.resource_name(0x7fd062e74e50)], [r.resource_show_seq(0x7fd062e75450)]), partitions(p0)
      is_index_back=false, is_global_index=false, 
      range_key([r.__pk_increment(0x7fd062e80b50)]), range(MIN ; MAX)always true
 13 - output([o.diag_obj_id(0x7fd062e4c850)], [o.diag_obj_name(0x7fd062e73c50)], [o.show_seq(0x7fd062e74250)], [rtag.rpt_tag(0x7fd062e5a2f0)]), filter(nil), rowset=256
      equal_conds([rtag.diag_obj_id(0x7fd062e59000) = o.diag_obj_id(0x7fd062e4c850)(0x7fd062e588b0)]), other_conds(nil)
      merge_directions([ASC])
 14 - output([o.diag_obj_id(0x7fd062e4c850)], [o.diag_obj_name(0x7fd062e73c50)], [o.show_seq(0x7fd062e74250)]), filter(nil), rowset=256
      equal_conds([rtag1.diag_obj_id(0x7fd062e5bbd0) = o.diag_obj_id(0x7fd062e4c850)(0x7fd062e5b480)]), other_conds(nil)
      merge_directions([ASC])
 15 - output([o.diag_obj_id(0x7fd062e4c850)], [o.diag_obj_name(0x7fd062e73c50)], [o.show_seq(0x7fd062e74250)]), filter(nil), rowset=256
      sort_keys([o.diag_obj_id(0x7fd062e4c850), ASC])
 16 - output([o.diag_obj_id(0x7fd062e4c850)], [o.diag_obj_name(0x7fd062e73c50)], [o.show_seq(0x7fd062e74250)]), filter(nil), rowset=256
      access([o.diag_obj_id(0x7fd062e4c850)], [o.diag_obj_name(0x7fd062e73c50)], [o.show_seq(0x7fd062e74250)]), partitions(p0)
      is_index_back=true, is_global_index=false, 
      range_key([o.diag_obj_type_id(0x7fd062e62120)], [o.diag_obj_id(0x7fd062e4c850)]), range(ZY,MIN ; ZY,MAX), (ZYFL,MIN ; ZYFL,MAX), (ZYX,MIN ; ZYX,MAX),
       
      range_cond([o.diag_obj_type_id(0x7fd062e62120) IN ('ZY', 'ZYFL', 'ZYX')(0x7fd062eabf40)(0x7fd062e607f0)])
 17 - output([rtag1.diag_obj_id(0x7fd062e5bbd0)]), filter(nil), rowset=256
      access([rtag1.diag_obj_id(0x7fd062e5bbd0)]), partitions(p0)
      is_index_back=false, is_global_index=false, 
      range_key([rtag1.rpt_tag(0x7fd062e63c40)], [rtag1.diag_obj_id(0x7fd062e5bbd0)]), range(全部,MIN ; 全部,MAX), 
      range_cond([rtag1.rpt_tag(0x7fd062e63c40) = '全部'(0x7fd062e62870)])
 18 - output([rtag.diag_obj_id(0x7fd062e59000)], [rtag.rpt_tag(0x7fd062e5a2f0)]), filter(nil), rowset=256
      access([rtag.diag_obj_id(0x7fd062e59000)], [rtag.rpt_tag(0x7fd062e5a2f0)]), partitions(p0)
      is_index_back=false, is_global_index=false, 
      range_key([rtag.diag_obj_id(0x7fd062e59000)], [rtag.rpt_tag(0x7fd062e5a2f0)]), range(MIN,MIN ; MAX,MAX)always true
 19 - output([a.diag_obj_id(0x7fd062e4c560)], [a.diagnostician_id(0x7fd062e51350)]), filter(nil), rowset=256
      access([a.diag_obj_id(0x7fd062e4c560)], [a.diagnostician_id(0x7fd062e51350)]), partitions(p63)
      is_index_back=false, is_global_index=false, 
      range_key([a.school_code(0x7fd062e4b1f0)], [a.school_term_id(0x7fd062e5ebc0)], [a.diag_obj_id(0x7fd062e4c560)], [a.diagnostician_id(0x7fd062e51350)],
       [a.ID(0x7fd062e80870)]), range(fsswgyxx,2411,MIN,MIN,MIN ; fsswgyxx,2411,MAX,MAX,MAX), 
      range_cond([a.school_code(0x7fd062e4b1f0) = 'fsswgyxx'(0x7fd062e5c170)], [cast(a.school_term_id(0x7fd062e5ebc0), DECIMAL(11, 0))(0x7fd062e5f130) = 
      cast('2411', DECIMAL(1, -1))(0x7fd062e5fc80)(0x7fd062e5d7f0)])
 20 - output([dtg.diagnostician_id(0x7fd062e57a10)], [dtg.tician_tag_name(0x7fd062e5a5e0)], [dtg.tician_tag_show_seq(0x7fd062e767e0)]), filter(nil), rowset=256
      access([dtg.diagnostician_id(0x7fd062e57a10)], [dtg.tician_tag_name(0x7fd062e5a5e0)], [dtg.tician_tag_show_seq(0x7fd062e767e0)]), partitions(p0)
      is_index_back=false, is_global_index=false, 
      range_key([dtg.school_code(0x7fd062e81f70)], [dtg.school_term_id(0x7fd062e82250)], [dtg.diagnostician_id(0x7fd062e57a10)], [dtg.school_seq(0x7fd062e82530)],
       [dtg.tician_tag(0x7fd062e82810)], [dtg.tician_tag_name(0x7fd062e5a5e0)]), range(MIN,MIN,MIN,MIN,MIN,MIN ; MAX,MAX,MAX,MAX,MAX,MAX)always true
 21 - output(nil), filter(nil), rowset=256
      access([GROUP_ID(0x7fce2e749d00)]), partitions(p0)
      is_index_back=false, is_global_index=false, 
      range_key([d.diagnostician_id(0x7fd062e51640)], [d.shadow_pk_0(0x7fd062fc9c60)], [d.shadow_pk_1(0x7fd062fc9f40)], [d.shadow_pk_2(0x7fd062fca220)],
       [d.shadow_pk_3(0x7fd062fcc410)]), range(MIN ; MAX), 
      range_cond([:4 = d.diagnostician_id(0x7fd062e51640)(0x7fc8d07f0260)])
 22 - output(nil), filter(nil), rowset=256
      access([GROUP_ID(0x7fce2e74be60)]), partitions(p0)
      is_index_back=false, is_global_index=false, 
      range_key([dt.diagnostician_type_id(0x7fd062e56130)], [dt.diagnostician_id(0x7fd062e54b40)], [dt.school_code(0x7fd062e816d0)], [dt.school_term_id(0x7fd062e819b0)],
       [dt.school_seq(0x7fd062e81c90)]), range(MIN ; MAX), 
      range_cond([dt.diagnostician_type_id(0x7fd062e56130) = 'XS'(0x7fd062ea8ba0)], [dt.diagnostician_id(0x7fd062e54b40) = :6(0x7fd000277830)])
Used Hint:
-------------------------------------
  /*+
      
  */
Qb name trace:
-------------------------------------
  stmt_id:0, stmt_type:T_EXPLAIN 
  stmt_id:1, SEL$1
  stmt_id:2, SEL$2 > SEL$B927DD92 > SEL$111DC835 > SEL$0D6D9CD6 > SEL$B15C285C
Outline Data: 
-------------------------------------
  /*+
      BEGIN_OUTLINE_DATA
      NO_USE_HASH_AGGREGATION(@"SEL$B15C285C" PARTITION_SORT)
      LEADING(@"SEL$B15C285C" ("edu_dw"."dt0"@"SEL$2" ((((("edu_dw"."r"@"SEL$2" (("edu_dw"."o"@"SEL$2" "edu_dw"."rtag1"@"SEL$2") "edu_dw"."rtag"@"SEL$2")) "edu_dw"."a"@"SEL$2") "edu_dw"."dtg"@"SEL$2") "edu_dw"."d"@"SEL$2") "edu_dw"."dt"@"SEL$2")))
      USE_NL(@"SEL$B15C285C" ("edu_dw"."rtag1"@"SEL$2" "edu_dw"."rtag"@"SEL$2" "edu_dw"."r"@"SEL$2" "edu_dw"."o"@"SEL$2" "edu_dw"."dtg"@"SEL$2" "edu_dw"."dt"@"SEL$2" "edu_dw"."d"@"SEL$2" "edu_dw"."a"@"SEL$2"))
      PQ_DISTRIBUTE(@"SEL$B15C285C" ("edu_dw"."rtag1"@"SEL$2" "edu_dw"."rtag"@"SEL$2" "edu_dw"."r"@"SEL$2" "edu_dw"."o"@"SEL$2" "edu_dw"."dtg"@"SEL$2" "edu_dw"."dt"@"SEL$2" "edu_dw"."d"@"SEL$2" "edu_dw"."a"@"SEL$2") LOCAL LOCAL)
      FULL(@"SEL$B15C285C" "dt0"@"SEL$2")
      USE_NL(@"SEL$B15C285C" "edu_dw"."dt"@"SEL$2")
      USE_NL(@"SEL$B15C285C" "edu_dw"."d"@"SEL$2")
      USE_HASH(@"SEL$B15C285C" "edu_dw"."dtg"@"SEL$2")
      USE_MERGE(@"SEL$B15C285C" "edu_dw"."a"@"SEL$2")
      USE_MERGE(@"SEL$B15C285C" ("edu_dw"."rtag1"@"SEL$2" "edu_dw"."rtag"@"SEL$2" "edu_dw"."o"@"SEL$2"))
      FULL(@"SEL$B15C285C" "r"@"SEL$2")
      USE_MERGE(@"SEL$B15C285C" "edu_dw"."rtag"@"SEL$2")
      USE_MERGE(@"SEL$B15C285C" "edu_dw"."rtag1"@"SEL$2")
      INDEX(@"SEL$B15C285C" "o"@"SEL$2" "t_d")
      INDEX(@"SEL$B15C285C" "rtag1"@"SEL$2" "tag_obj_1")
      FULL(@"SEL$B15C285C" "rtag"@"SEL$2")
      INDEX(@"SEL$B15C285C" "a"@"SEL$2" "diag_obj_id_diagnostician_id")
      FULL(@"SEL$B15C285C" "dtg"@"SEL$2")
      INDEX(@"SEL$B15C285C" "d"@"SEL$2" "diagnostician_id")
      USE_DAS(@"SEL$B15C285C" "d"@"SEL$2")
      INDEX(@"SEL$B15C285C" "dt"@"SEL$2" "d_t")
      USE_DAS(@"SEL$B15C285C" "dt"@"SEL$2")
      REPLACE_CONST(@"SEL$2")
      MERGE(@"SEL$B927DD92" < "SEL$1")
      OUTER_TO_INNER(@"SEL$111DC835")
      PRED_DEDUCE(@"SEL$0D6D9CD6")
      OPTIMIZER_FEATURES_ENABLE('4.0.0.0')
      END_OUTLINE_DATA
  */
Optimization Info:
-------------------------------------
  dt0:
      table_rows:9
      physical_range_rows:1
      logical_range_rows:1
      index_back_rows:0
      output_rows:1
      table_dop:1
      dop_method:Table DOP
      avaiable_index_name:[diagnostician_type_id, dw_diagnostician_type]
      pruned_index_name:[diagnostician_type_id]
      stats version:1715177800396252
      dynamic sampling level:0
  r:
      table_rows:5817
      physical_range_rows:6345
      logical_range_rows:5751
      index_back_rows:0
      output_rows:5751
      table_dop:1
      dop_method:Table DOP
      avaiable_index_name:[diag_obj_id, v_diag_obj_resource]
      stats version:1715176850282535
      dynamic sampling level:0
  o:
      table_rows:756608
      physical_range_rows:5131
      logical_range_rows:5049
      index_back_rows:5049
      output_rows:5049
      table_dop:1
      dop_method:Table DOP
      avaiable_index_name:[school_code, s_s_t_d, d_t, t_d, diag_obj_id, dw_diag_obj]
      pruned_index_name:[school_code, s_s_t_d, d_t, diag_obj_id]
      stats version:1715177851810419
      dynamic sampling level:0
  rtag1:
      table_rows:1054757
      physical_range_rows:758221
      logical_range_rows:753383
      index_back_rows:0
      output_rows:753383
      table_dop:1
      dop_method:Table DOP
      avaiable_index_name:[diag_obj_id, tag_obj, tag_obj_1, rpt_tag, dw_diag_obj_rpt_tag]
      pruned_index_name:[diag_obj_id, tag_obj, dw_diag_obj_rpt_tag]
      stats version:1715091401445868
      dynamic sampling level:0
  rtag:
      table_rows:1054757
      physical_range_rows:1065316
      logical_range_rows:1060072
      index_back_rows:0
      output_rows:1060072
      table_dop:1
      dop_method:Table DOP
      avaiable_index_name:[diag_obj_id, tag_obj, tag_obj_1, rpt_tag, dw_diag_obj_rpt_tag]
      stats version:1715091401445868
      dynamic sampling level:0
  a:
      table_rows:1166518
      physical_range_rows:2727708
      logical_range_rows:890075
      index_back_rows:0
      output_rows:890075
      table_dop:1
      dop_method:Table DOP
      avaiable_index_name:[naire_answer_rec_id, diag_obj_id_diagnostician_id, diag_obj_id_q_id, diag_obj_id, diagnostician_id, school_code, school_term_id, q_id, school_seq, idx_school_term_qid, answer, idx_schoolcode_termid_qid, dw_actual_answer_naire_question]
      pruned_index_name:[naire_answer_rec_id, diag_obj_id_q_id, diag_obj_id, school_code, school_term_id, q_id, school_seq, idx_school_term_qid, answer, idx_schoolcode_termid_qid, dw_actual_answer_naire_question]
      stats version:1715178531266868
      dynamic sampling level:0
  dtg:
      table_rows:5017979
      physical_range_rows:5162920
      logical_range_rows:5066761
      index_back_rows:0
      output_rows:5066761
      table_dop:1
      dop_method:Table DOP
      avaiable_index_name:[school_seq, diagnostician_id, tician_tag, school_code, school_term_id, tician_tag_name, diagnostician_tician_tag_name, dw_tician_tag]
      pruned_index_name:[school_seq, tician_tag, school_code, school_term_id]
      stats version:1715176874327844
      dynamic sampling level:0
  d:
      table_rows:1679889
      physical_range_rows:1
      logical_range_rows:1
      index_back_rows:0
      output_rows:1
      table_dop:1
      dop_method:DAS DOP
      avaiable_index_name:[diagnostician_id, school_code, school_seq, school_term_id, school_code_2, idx_code, diagnostician_type_id, dw_diagnostician]
      pruned_index_name:[school_code, school_seq, school_term_id, school_code_2, idx_code, diagnostician_type_id, dw_diagnostician]
      stats version:1704291123472779
      dynamic sampling level:0
  dt:
      table_rows:2156505
      physical_range_rows:1
      logical_range_rows:1
      index_back_rows:0
      output_rows:1
      table_dop:1
      dop_method:DAS DOP
      avaiable_index_name:[school_seq, diagnostician_type_id, diagnostician_id, school_term_id, school_code, d_t, idx_d_id, dw_tician_type]
      pruned_index_name:[school_seq, diagnostician_type_id, school_term_id, school_code, idx_d_id, dw_tician_type]
      stats version:1715176861845681
      dynamic sampling level:0
  Plan Type:
      DISTRIBUTED
  Note:
      Degree of Parallelisim is 1 because of table property

您好,这个是报表系统自动生成的,我们修改为100也一样慢

在第二个select处,加上如下hint试试
/*+ LEADING(dt0 dt d a o) */

加上还是很慢,和之前一样,但是加上/+NO_REWRITE/ 很快,和不加limit语句执行时间一样?是ob重写sql优化问题?