oracle sql语句的union效率问题【急】【急】【急】

来源:百度知道 编辑:UC知道 时间:2024/05/04 11:22:16
请教大家一个问题:
oracle查询 有三个sql 查询出的字段是相同的。
sql1 用了10s ,sql2用了5s,sql3用了10s
我查询 sql1 union all sql2 union all sql3怎么就查询不出来呢?耗时很久了都死活不出数据。

前提跟大家说一下,查询表是大约有10万数据量,每个sql都有单独的统计逻辑。
语句太复杂:简单概括两种情况
select s1.vendorid, s1.dn,s1.node, SUM(clear_during) duration
from (
/*情况1*/ select his.vendorid,
his.node,
his.dn,
his.occur_time,
his.clr_time,
clear_during
from rt_data_al_00_ecpex his
where his.occur_time <=
to_date('2008-4-12 23:59:00','yyyy-mm-dd hh24:mi:ss')
and his.clr_time >
to_date('2008-4-12 23:59:00','yyyy-mm-dd hh24:mi:ss')
and vendorid=3
and network_type=15 and clr_by='system'
union all
/*情况2*/
--sql省略,跟第一种情况想象,因为补充问

建临时表

把语句贴出来,你不要group by的吗?是不是忘记了?如果有的话请先执行嵌套表S1,s1可以查询出来了再做聚合

select s1.vendorid, s1.dn,s1.node, SUM(clear_during) duration
from (
/*情况1*/ select his.vendorid,
his.node,
his.dn,
his.occur_time,
his.clr_time,
clear_during
from rt_data_al_00_ecpex his
where his.occur_time <=
to_date('2008-4-12 23:59:00','yyyy-mm-dd hh24:mi:ss')
and his.clr_time >
to_date('2008-4-12 23:59:00','yyyy-mm-dd hh24:mi:ss')
and vendorid=3
and network_type=15 and clr_by='system'
union all
/*情况2*/
--sql省略,跟第一种情况想象,因为补充问题有字数限制,所以不再粘贴
) s1
group by s1.vendorid, s1.dn,s1.node

请问 你不是说3个句子?

也不太复杂,最好还是把全部的sql贴出来,想办法贴出来,这样更好分析效率。