代码中,去掉括号不会全表扫描,走索引.加括号 不走索引,全表扫描,走netedloop. 加hint /* use_hash */ 和去掉括号一样,走索引,走hash
bug ?
select *
from (select tblha0_.ID
as ID13_,
tblha0_.INIT_ID as INIT2_13_,
tblha0_.RECORD_DATE as RECORD3_13_,
tblha0_.SRQYas SRQY13_,
tblha0_.CRJ as CRJ13_,
tblha0_.DRQYas DRQY13_,
tblha0_.ZYJ as ZYJ13_,
tblha0_.DRDWFSas DRDWFS13_,
tblha0_.DRDWJZas DRDWJZ13_,
tblha0_.DRDWCJas DRDWCJ13_,
tblha0_.LJDWJZas LJDWJZ13_,
tblha0_.LJSYL as LJSYL13_,
tblha0_.ZYJBD as ZYJBD13_,
tblha0_.CJJEas CJJE13_,
tblha0_.LJYKE as LJYKE13_,
tblha0_.YYB as YYB13_,
tblha0_.FXL as FXL13_,
tblha0_.SXF as SXF13_,
tblha0_.LCSXF as LCSXF13_,
tblha0_.DSYKas DSYK13_,
tblha0_.KYZJas KYZJ13_,
tblha0_.BZJ as BZJ13_,
tblha0_.FDYKas FDYK13_,
tblha0_.ZJBZJ as ZJBZJ13_,
tblha0_.JYSFXLas JYSFXL13_,
tblha0_.JYSBZJas JYSBZJ13_,
tblha0_.LJBJas LJBJ13_,
tblha0_.CJ
as CJ13_,
tblha0_.RJ
as RJ13_,
tblha0_.DRLJDWCJas DRLJDWCJ13_,
tblha0_.ADD_NUM as ADD31_13_,
tblha0_.LJCJJEas LJCJJE13_,
tblha0_.LJCRJ as LJCRJ13_
from KIIIK.TB_LH_A tblha0_, KIIIK.TB_LH_INIT tblhinit1_
where tblha0_.INIT_ID = tblhinit1_.ID
and tblha0_.RECORD_DATE = :1
and tblhinit1_.MILITARY_SERVICE = :2
and ( tblha0_.LJYKE is not null ) -- 此处加括号执行计划不同.
order by tblha0_.LJYKE desc)
where rownum <= :3
[ 本帖最后由 ouyangzi 于 2010-2-5 15:03 编辑 ]
|