日期:2014-05-17  浏览次数:20892 次

请问一条语句的效率问题...
SQL code

select
aa.maintenance_record_id,aa.vehicle_tag_no,aa.vehicle_no_color,aa.undercarriage_no,aa.MASTER_NAME,
aa.ID_CARD_NO,aa.MOBILE,aa.maintenance_date,aa.maintenance_user,aa.maintenance_zone,aa.maintenance_item,
aa.maintenance_description ,vira.PASSED 
from 
(select sdv.maintenance_record_id,sdv.vehicle_tag_no,sdv.vehicle_no_color,sdv.undercarriage_no,vbi.MASTER_NAME,
vbi.ID_CARD_NO,vbi.MOBILE,sdv.maintenance_date,sdv.maintenance_user,sdv.maintenance_zone,sdv.maintenance_item,
sdv.maintenance_description
from service_depot_vehicle sdv,vehicle_base_info vbi
where 1=1 and sdv.vehicle_tag_no = vbi.vehicle_tag_no and sdv.undercarriage_no = vbi.undercarriage_no 
order by sdv.MAINTENANCE_RECORD_ID) aa,v_inpection_result_all vira
where aa.vehicle_tag_no = vira.VEHICLE_TAG_NO and aa.undercarriage_no = vira.undercarriage_no and  rownum <= 200 



SQL code
select
aa.maintenance_record_id,aa.vehicle_tag_no,aa.vehicle_no_color,aa.undercarriage_no,aa.MASTER_NAME,
aa.ID_CARD_NO,aa.MOBILE,aa.maintenance_date,aa.maintenance_user,aa.maintenance_zone,aa.maintenance_item,
aa.maintenance_description ,vira.PASSED 
from 
(select sdv.maintenance_record_id,sdv.vehicle_tag_no,sdv.vehicle_no_color,sdv.undercarriage_no,vbi.MASTER_NAME,
vbi.ID_CARD_NO,vbi.MOBILE,sdv.maintenance_date,sdv.maintenance_user,sdv.maintenance_zone,sdv.maintenance_item,
sdv.maintenance_description
from service_depot_vehicle sdv,vehicle_base_info vbi
where 1=1 and sdv.vehicle_tag_no = vbi.vehicle_tag_no and sdv.undercarriage_no = vbi.undercarriage_no ) aa,v_inpection_result_all vira
where aa.vehicle_tag_no = vira.VEHICLE_TAG_NO and aa.undercarriage_no = vira.undercarriage_no and  rownum <= 200 



SQL code
select
*
from 
(select sdv.maintenance_record_id,sdv.vehicle_tag_no,sdv.vehicle_no_color,sdv.undercarriage_no,vbi.MASTER_NAME,
vbi.ID_CARD_NO,vbi.MOBILE,sdv.maintenance_date,sdv.maintenance_user,sdv.maintenance_zone,sdv.maintenance_item,
sdv.maintenance_description
from service_depot_vehicle sdv,vehicle_base_info vbi,v_inpection_result_all vira
where 1=1 and sdv.vehicle_tag_no = vbi.vehicle_tag_no and sdv.undercarriage_no = vbi.undercarriage_no 
and sdv.vehicle_tag_no = vira.VEHICLE_TAG_NO and sdv.undercarriage_no = vira.undercarriage_no
order by sdv.MAINTENANCE_RECORD_ID)
where rownum <= 200 



这三条语句,得到的结果应该是一样的...但是效率相差很大...请大家帮忙分析下原因...非常感谢...

------解决方案--------------------
先再每个表中筛选出结果,再做连接