我正在生产(Oracle)中运行此查询,它耗时超过3分钟。有什么办法可以减少执行时间?svc_order和事件表均包含近一百万条记录。
select 0 test_section, count(1) count, 'DD' test_section_value from svc_order so, event e where so.svc_order_id = e.svc_order_id and so.entered_date >= to_date('01/01/2012', 'MM/DD/YYYY') and e.event_type = 230 and e.event_level = 'O' and e.current_sched_date between to_date( '09/01/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS') and to_date('09/29/2013 23:59:59', 'MM/DD/YYYY HH24:MI:SS') and (((so.sots_ta = 'N') and (so.action_type = 0)) or ((so.sots_ta is null) and (so.action_type = 0)) or ((so.sots_ta = 'N') and (so.action_type is null))) and so.company_code = 'LL'
查看您说的无法创建索引的内容。我希望查询对表进行全表扫描。请尝试并行提示。
select /*+ full(so) parallel(so, 4) */ 0 test_section, count(1) count, 'DD' test_section_value from svc_order so, event e where so.svc_order_id = e.svc_order_id and so.entered_date >= to_date('01/01/2012', 'MM/DD/YYYY') and e.event_type = 230 and e.event_level = 'O' and e.current_sched_date between to_date( '09/01/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS') and to_date('09/29/2013 23:59:59', 'MM/DD/YYYY HH24:MI:SS') and (((so.sots_ta = 'N') and (so.action_type = 0)) or ((so.sots_ta is null) and (so.action_type = 0)) or ((so.sots_ta = 'N') and (so.action_type is null))) and so.company_code = 'LL'