oracle中unionall优化,【讨论】UNIONALL语句优化SQL> select owner , view_name , text from dba_views where view_name='V_WARM_ASSET';
OWNER      VIEW_NAME  TEXT
---------- ---------- --------------------------------------------------
ALCM      V_WARM_ASS select '500kV' as 类别,
ET                sum(case
when status = '运⾏中' then
1
else
end) as 正常,
sum(case
when status = '停⽌使⽤' then
1
else
end) as 异常,
sum(case
when status = '删除' then
1
else
end) as 停运
from sc_asset t
where t.ydtf_dydj = 1
union all
select '220kV' as 类别,
sum(case
when status = '运⾏中' then
else
1
end) as 正常,
sum(case
when status = '停⽌使⽤' then 1
else
end) as 异常,
sum(case
when status = '删除' then
1
else
end) as 停运
from sc_asset t
where t.ydtf_dydj = 2
sql中union多表合并union all
select '110kV' as 类别,
sum(case
when status = '运⾏中' then
1
else
end) as 正常,
sum(case
when status = '停⽌使⽤' then 1
else
end) as 异常,
sum(case
when status = '删除' then
1
else
end) as 停运
from sc_asset t
where t.ydtf_dydj = 3
union all
select '其它等级' as 类别,
sum(case
when status = '运⾏中' then
1
else
end) as 正常,
sum(case
when status = '停⽌使⽤' then
1
else
end) as 异常,
sum(case
when status = '删除' then
1
else
end) as 停运
from sc_asset t
where t.ydtf_dydj not in (1, 2, 3)
union all
/
*设备类型*/
。。。
就是这么⼀个语句,有⼗多个union all,运⾏直接把服务器拖死,⼤家看看要怎么优化呢?附件⾥⾯是完整的语句
2014-10-15 14:27 上传
点击⽂件名下载附件
16.32 KB, 下载次数: 40

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。