select b.productdutycode,b.producttypecode,p.insuredcode,p.instcode, p.applcode, p.polcode, p.productcode, p.newamt, p.newprem, p.effdate, p.feeinperiod, p.insurperiod,p.termdate,p.expirydate,p.feeinway, p.polstate, p.drawtime, p.appldate, p.insurperiodtype, p.feeinperiodtype,p.firstprm from icont_polinfo p join base_prod_type_rel b on substr(p.productcode, 1, 3) = substr(b.productdutycode,1,3) where insuredcode='2009000001600010223' and effdate<= to_date('2011-02-25','YYYY-MM-DD') and p.instcode='410000' and (p.expirydate>= to_date('2011-02-25','YYYY-MM-DD') or p.expirydate is null) and b.productdutycode = 'D40' order by p.effdate ,b.puborder desc, p.applcode 怎么优化这个sql语句
看了我就是发现一个可以改进的地方,就是
to_date这个函数去掉,不要用函数,你去掉函数看看和没有去掉函数看看,是否有区别。
不要用函数就改为其他的如Convert(varchar(?),'2011-02-25',?)来代替。
on 条件有问题.用到用全表扫描哦.