ITPub博客

首页 > Linux操作系统 > Linux操作系统 > oracle优化与可持续运行

oracle优化与可持续运行

原创 Linux操作系统 作者:lfree 时间:2006-12-30 00:00:00 0 删除 编辑

最近很长一段时间都在优化一个项目,这个项目存在许多问题,从数据架构到工作流
程,我一直在思考一些有关oracle性能优化的问题,我跟开发实施人员进行过多次交流,
发现存在许多交流障碍,许多问题实施人员觉得sql语句执行很快,并不存在性能问题,
我花了大量时间要他看执行计划,说明当数据积累到一定时间后,会执行越来越慢。

我拿一个例子来说明问题:

SELECT v2.*
FROM consultationrecorddoctor t1
RIGHT OUTER JOIN
(SELECT cr.*, crc.modifydate, crc.modifyuserid, crc.consultationtime,
crc.applyconsultationdeptid, crc.askconsultationdeptid,
crc.consultationdeptid, crc.casehistory_right,
crc.consultationorder_right, crc.consultationidea_right,
crc.otherhospital_right, crc.consultationdate,
crc.maindoctorid, c1.deptname_vchr AS applydeptname,
c2.deptname_vchr AS askdeptname,
c3.deptname_vchr AS deptname,
f_getempnamebyno (crc.maindoctorid) AS maindocname
FROM consultationrecord cr,
consultationrecordcontent crc,
t_bse_deptdesc c1,
t_bse_deptdesc c2,
t_bse_deptdesc c3,
(SELECT cr.inpatientid, cr.inpatientdate, cr.opendate,
cr.createdate,
MAX (crc.modifydate) AS maxmodifydate
FROM consultationrecord cr,
consultationrecordcontent crc
WHERE (crc.applyconsultationdeptid = '0000208')
AND cr.inpatientid = crc.inpatientid
AND cr.inpatientdate = crc.inpatientdate
AND cr.opendate = crc.opendate
AND cr.status = 0
GROUP BY cr.inpatientid,
cr.inpatientdate,
cr.opendate,
cr.createdate) v1
WHERE (crc.applyconsultationdeptid = '0000208')
AND cr.inpatientid = crc.inpatientid
AND cr.inpatientdate = crc.inpatientdate
AND cr.opendate = crc.opendate
AND cr.status = 0
AND crc.applyconsultationdeptid = c1.deptid_chr
AND crc.askconsultationdeptid = c2.deptid_chr
AND crc.consultationdeptid = c3.deptid_chr
AND cr.inpatientid = v1.inpatientid
AND cr.inpatientdate = v1.inpatientdate
AND cr.opendate = v1.opendate
AND v1.maxmodifydate = crc.modifydate
AND crc.maindoctorid IS NOT NULL) v2
ON t1.inpatientid = v2.inpatientid
AND t1.inpatientdate = v2.inpatientdate
AND t1.opendate = v2.opendate
AND t1.modifydate = v2.modifydate
AND t1.employeeflag = 1
WHERE t1.employeeid IS NULL
ORDER BY t1.employeeid DESC, v2.askdeptname, v2.consultationdate;


查询使用了一个右连接,查询的表并没有包含t1表的字段,而且在实际的t1.employeeid中
根本不存在NULL的值,实际上是从一个大的结果集剔除一个大结果集的而获得一个小的结
果集,随着crc表数据量加大,会越来越慢!


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/267265/viewspace-82960/,如需转载,请注明出处,否则将追究法律责任。

上一篇: vim与colour schema
请登录后发表评论 登录
全部评论
熟悉oracle相关技术,擅长sql优化,rman备份与恢复,熟悉linux shell编程。

注册时间:2008-01-03

  • 博文量
    3399
  • 访问量
    7101207