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

0

end) as 正常,

sum(case

when status = '停止使用' then

1

else

0

end) as 异常,

sum(case

when status = '删除' then

1

else

0

end) as 停运

from sc_asset t

where t.ydtf_dydj = 1

union all

select '220kV' as 类别,

sum(case

when status = '运行中' then

else

1

0

end) as 正常,

sum(case

when status = '停止使用' then

1

else

0

end) as 异常,

sum(case

when status = '删除' then

1

else

0

end) as 停运

from sc_asset t

where t.ydtf_dydj = 2

union all

select '110kV' as 类别,

sum(case

when status = '运行中' then

1

else

0

end) as 正常,

sum(case

when status = '停止使用' then

1

else

0

end) as 异常,

sum(case

when status = '删除' then

1

else

0

end) as 停运

from sc_asset t

where t.ydtf_dydj = 3

union all

select '其它等级' as 类别,

sum(case

when status = '运行中' then

1

else

0

end) as 正常,

sum(case

when status = '停止使用' then

1

else

0

end) as 异常,

sum(case

when status = '删除' then

1

else

0

end) as 停运

from sc_asset t

where t.ydtf_dydj not in (1, 2, 3)

union all

/*设备类型*/

。。。

就是这么一个语句,有十多个union all,运行直接把服务器拖死,大家看看要怎么优化呢?

附件里面是完整的语句

267abf8789d6bad6eaf3c8c87b18d9ed.gif

2014-10-15 14:27 上传

点击文件名下载附件

16.32 KB, 下载次数: 40

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐