当前位置: 代码迷 >> Oracle开发 >> 请教一条语句的效率有关问题.
  详细解决方案

请教一条语句的效率有关问题.

热度:396   发布时间:2016-04-24 08:04:15.0
请问一条语句的效率问题...
SQL code
selectaa.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_descriptionfrom service_depot_vehicle sdv,vehicle_base_info vbiwhere 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 virawhere aa.vehicle_tag_no = vira.VEHICLE_TAG_NO and aa.undercarriage_no = vira.undercarriage_no and  rownum <= 200 


SQL code
selectaa.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_descriptionfrom service_depot_vehicle sdv,vehicle_base_info vbiwhere 1=1 and sdv.vehicle_tag_no = vbi.vehicle_tag_no and sdv.undercarriage_no = vbi.undercarriage_no ) aa,v_inpection_result_all virawhere 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_descriptionfrom service_depot_vehicle sdv,vehicle_base_info vbi,v_inpection_result_all virawhere 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_noorder by sdv.MAINTENANCE_RECORD_ID)where rownum <= 200 



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

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