查看: 5507|回复: 28

[原创] 一次oracle调优的相关经历

[复制链接]
论坛徽章:
8
授权会员
日期:2005-10-30 17:05:33ITPUB元老
日期:2007-10-04 13:18:29ITPUB十周年纪念徽章
日期:2011-11-01 16:19:41ITPUB社区12周年站庆徽章
日期:2013-10-08 17:44:42一汽
日期:2013-11-01 11:06:26
跳转到指定楼层
1#
发表于 2011-8-17 11:31 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
该死的10000字限定,只能上传文件啦。

发票打印程序调优.TXT

32.79 KB, 下载次数: 186

论坛徽章:
8
授权会员
日期:2005-10-30 17:05:33ITPUB元老
日期:2007-10-04 13:18:29ITPUB十周年纪念徽章
日期:2011-11-01 16:19:41ITPUB社区12周年站庆徽章
日期:2013-10-08 17:44:42一汽
日期:2013-11-01 11:06:26
2#
 楼主| 发表于 2011-8-17 11:33 | 只看该作者

好久不来itpub

欢迎大家多提意见,多多指教。

使用道具 举报

回复
招聘 : 数据库管理员
论坛徽章:
46
ITPUB元老
日期:2011-08-06 00:48:09最佳人气徽章
日期:2012-03-13 17:39:18版主1段
日期:2013-03-07 02:21:02ITPUB季度 技术新星
日期:2011-11-18 16:54:31ITPUB伯乐
日期:2012-02-16 14:53:44ITPUB北京2009年会纪念徽章
日期:2009-02-09 11:42:45会员2007贡献徽章
日期:2007-09-26 18:42:10玉石琵琶
日期:2012-02-21 15:04:38授权会员
日期:2007-01-26 09:19:03数据库板块每日发贴之星
日期:2011-08-04 01:01:01
3#
发表于 2011-8-17 11:56 | 只看该作者
鼓励原创,好像就是统计信息不及时更想,导致错误的执行计划。

使用道具 举报

回复
招聘 : 数据库管理员
论坛徽章:
46
ITPUB元老
日期:2011-08-06 00:48:09最佳人气徽章
日期:2012-03-13 17:39:18版主1段
日期:2013-03-07 02:21:02ITPUB季度 技术新星
日期:2011-11-18 16:54:31ITPUB伯乐
日期:2012-02-16 14:53:44ITPUB北京2009年会纪念徽章
日期:2009-02-09 11:42:45会员2007贡献徽章
日期:2007-09-26 18:42:10玉石琵琶
日期:2012-02-21 15:04:38授权会员
日期:2007-01-26 09:19:03数据库板块每日发贴之星
日期:2011-08-04 01:01:01
4#
发表于 2011-8-17 12:09 | 只看该作者
lz的两个脚本看上去比较有意思,能否传上来。

使用道具 举报

回复
论坛徽章:
8
授权会员
日期:2005-10-30 17:05:33ITPUB元老
日期:2007-10-04 13:18:29ITPUB十周年纪念徽章
日期:2011-11-01 16:19:41ITPUB社区12周年站庆徽章
日期:2013-10-08 17:44:42一汽
日期:2013-11-01 11:06:26
5#
 楼主| 发表于 2011-8-17 12:28 | 只看该作者

topsql1脚本

col MESSAGE format a40;
  col username format a10;
  set linesize 350;
  set pagesize 50;
  col program format a30;
  
  select * from (  select sid,USERNAME,MESSAGE,ELAPSED_SECONDS, TIME_REMAINING from v$session_longops  where  TIME_REMAINING is not null order by ELAPSED_SECONDS desc ) where rownum<10;
  --prompt ===============================sql catched by sum ELAPSED_SECONDS====================;
  select * from (  select sid,USERNAME,MESSAGE,ELAPSED_SECONDS, TIME_REMAINING from v$session_longops  where  TIME_REMAINING is not null order by TIME_REMAINING desc ) where rownum<10;
    prompt ================================================================================
   prompt =============================get top file scattered read objects===================;
    select * from (select target ,count(*) from v$session_longops group by target order by 2 desc) where rownum<10;
truncate table merch.session_longops_temp ;
insert into session_longops_temp select * from v$session_longops   where  TIME_REMAINING>60;
commit;
select a.sid,a.username,a.program ,b.TIME_REMAINING from v$session a ,session_longops_temp b where a.sid=b.sid    order by 4 desc;

注意session_longops_temp表是自建,为提高v$session_longops 的查询效率。

使用道具 举报

回复
论坛徽章:
8
授权会员
日期:2005-10-30 17:05:33ITPUB元老
日期:2007-10-04 13:18:29ITPUB十周年纪念徽章
日期:2011-11-01 16:19:41ITPUB社区12周年站庆徽章
日期:2013-10-08 17:44:42一汽
日期:2013-11-01 11:06:26
6#
 楼主| 发表于 2011-8-17 12:31 | 只看该作者

checksid脚本

accept sid prompt 'Enter sid [%] :'
set linesize 180;
col object_name format a30;
col description format a50;
col sessions  format a30;
col program format a20;
col message format a40;
col SCHEMA_USER format a10;
col what format a50;
col INTERVAL format a20;
col usermame format a10;
alter session set nls_date_format='yyyy/mm/dd hh24:mi:ss';
select username,osuser,process,terminal,machine,status,program from v$session where sid=&sid;
select sid,job from dba_jobs_running where sid=&sid;
select JOB,SCHEMA_USER,what,LAST_SEC,INTERVAL from dba_jobs where job in (select job from dba_jobs_running where sid=&sid);
select /*+ ordered */ c.sid, d.sql_id,d.hash_value,d.sql_text from   sys.v_$session c, sys.v_$sqltext d where   c.sid in (&sid) and    c.sql_address = d.address and    c.sql_hash_value = d.hash_value order by  c.sid, d.piece;
select sid,USERNAME,MESSAGE,ELAPSED_SECONDS, TIME_REMAINING from v$session_longops  where  TIME_REMAINING is not null and sid=&sid;
select a.sid||','||a.serial# sessions ,a.username,substr(a.program,1,15) program ,c.object_name  from v$session a ,v$locked_object b ,dba_objects c  where a.sid=&sid and a.sid=b.session_id and b.object_id=c.object_id order by 1;

select t.*
from v$sql s
   , table(dbms_xplan.display_cursor(s.sql_id,s.child_number,'ALLSTATS LAST')) t where s.sql_id  in (select  distinct d.sql_id from   sys.v_$session c, sys.v_$sqltext d where   c.sid in (&sid) and    c.sql_address = d.address and    c.sql_hash_value = d.hash_value ) ;



以上数据库版本为10.2.0.4,仅供参考。

使用道具 举报

回复
论坛徽章:
137
ITPUB元老
日期:2008-05-10 12:57:22技术图书徽章
日期:2017-02-09 13:57:14乌索普
日期:2016-12-02 17:48:27妮可·罗宾
日期:2016-08-16 08:59:24弗兰奇
日期:2016-07-01 14:42:52双鱼座
日期:2016-06-17 11:46:40水瓶座
日期:2016-04-12 17:02:05白羊座
日期:2016-01-05 15:11:44狮子座
日期:2015-12-23 11:16:56山治
日期:2022-07-07 11:21:34
7#
发表于 2011-8-17 12:47 | 只看该作者
不错。 支持。

使用道具 举报

回复
论坛徽章:
7
数据库板块每日发贴之星
日期:2011-06-14 01:01:02数据库板块每日发贴之星
日期:2011-08-16 01:01:01ITPUB十周年纪念徽章
日期:2011-09-27 16:34:13ITPUB十周年纪念徽章
日期:2011-11-01 16:26:592012新春纪念徽章
日期:2012-01-04 11:57:56玉石琵琶
日期:2012-02-21 15:04:382013年新春福章
日期:2013-02-25 14:51:24
8#
发表于 2011-8-17 13:44 | 只看该作者
为什么有个索引会突然出故障?

使用道具 举报

回复
论坛徽章:
8
授权会员
日期:2005-10-30 17:05:33ITPUB元老
日期:2007-10-04 13:18:29ITPUB十周年纪念徽章
日期:2011-11-01 16:19:41ITPUB社区12周年站庆徽章
日期:2013-10-08 17:44:42一汽
日期:2013-11-01 11:06:26
9#
 楼主| 发表于 2011-8-17 14:07 | 只看该作者
基于成本的优化策略会根据统计信息来决定SQL的执行路径

DML操作会使得数据库表的实际信息与之前的统计信息发生误差。

使用道具 举报

回复
论坛徽章:
37
2008新春纪念徽章
日期:2008-02-13 12:43:032010广州亚运会纪念徽章:击剑
日期:2011-01-22 20:59:112011新春纪念徽章
日期:2011-02-18 11:43:33茶鸡蛋
日期:2011-08-05 15:44:24ITPUB十周年纪念徽章
日期:2011-11-01 16:21:152012新春纪念徽章
日期:2012-01-04 11:51:22玉石琵琶
日期:2012-02-21 15:04:38ITPUB 11周年纪念徽章
日期:2012-10-09 18:06:202013年新春福章
日期:2013-02-25 14:51:24劳斯莱斯
日期:2013-09-12 15:56:37
10#
发表于 2011-8-17 14:22 | 只看该作者
不错。学习

使用道具 举报

回复

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

TOP技术积分榜 社区积分榜 徽章 团队 统计 知识索引树 积分竞拍 文本模式 帮助
  ITPUB首页 | ITPUB论坛 | 数据库技术 | 企业信息化 | 开发技术 | 微软技术 | 软件工程与项目管理 | IBM技术园地 | 行业纵向讨论 | IT招聘 | IT文档
  ChinaUnix | ChinaUnix博客 | ChinaUnix论坛
CopyRight 1999-2011 itpub.net All Right Reserved. 北京盛拓优讯信息技术有限公司版权所有 联系我们 未成年人举报专区 
京ICP备16024965号-8  北京市公安局海淀分局网监中心备案编号:11010802021510 广播电视节目制作经营许可证:编号(京)字第1149号
  
快速回复 返回顶部 返回列表