利用视图可以提高sql效率么?
时间:2011-12-19
来源:互联网
附上sql:
select /*+ parallel(his,8) */ his.idva, b.opnid
from
(select mobile from CH_BBC_ALLSALES where calcmonth='201111' union all
select mobile from CH_BBC_CONTDATA where calcmonth='201111' union all
select mobile from CH_BBC_WADTTASK where calcmonth='201111') t, CH_BBC_JFOPNMAP b, DSMPUSERDATA_HIS his
where
his.idva=t.mobile
and his.spid=b.entid
and his.SPBIZCODE=b.busiid
and his.opr='07'
and to_date(his.efftt,'yyyymmddhh24miss') between add_months(to_date('20111101','yyyymmdd'),-2) and to_date('20111130235959','yyyymmddhh24miss')
union all
select a.servnumber, b.opnid from
(select /*+ parallel(b,8) */ b.subsid, b.canceloid, c.opnid from CM_SUBS_SPSERVICE b, CH_BBC_JFOPNMAP c
where b.spid=c.entid and b.spbizid=c.busiid) b,
(select /*+ parallel(rec,8) */ rec.servnumber, rec.entityid, rec.oid from
(select mobile from CH_BBC_ALLSALES where calcmonth='201111' union all
select mobile from CH_BBC_CONTDATA where calcmonth='201111' union all
select mobile from CH_BBC_WADTTASK where calcmonth='201111') t, CS_REC_RECEPTION rec
where rec.servnumber=t.mobile
and rec.recdefid='Cancel'
and rec.recdate between add_months(to_date('20111101','yyyymmdd'),-2) and to_date('20111130235959','yyyymmddhh24miss')) a
where a.entityid=b.subsid and a.oid=b.canceloid;
作者: haiying2099 发布时间: 2011-12-19
作者: forgetsam 发布时间: 2011-12-19
作者: haiying2099 发布时间: 2011-12-19
作者: BearFishShow 发布时间: 2011-12-19
作者: viszl 发布时间: 2011-12-19
作者: zhangna08 发布时间: 2011-12-19
我觉得你这个地方不是视图的问题,而是语句本身就有点复杂,你可以先把结果保存到中间表,然后你再拿中间表的数据,跑到中间表的过程以跑批的形式执行.
增加中间表会增加数据的空间,这个不现实呀,就算是中间表,数据也可能上千万数据的。
作者: haiying2099 发布时间: 2011-12-19
物化视图可以
这个是否会增加数据的占用空间?
作者: haiying2099 发布时间: 2011-12-19
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28