已阅读5页,还剩1页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
-数据库巡检或性能优化方法各异,但首要的是要发现数据库性能瓶颈,系统自带的statspack,或awr太耗时,-以下是本人常用的方法,共享之-1、查询数据库等待事件top10,关注前前几个等待事件,关注前三个等待事件是否有因果或关联关系-oracle 9iselect t2.event,round(100*t2.time_waited/(t1.w1+t3.cpu),2) event_wait_percent from (SELECT SUM(time_waited) w1 FROM v$system_event WHERE event NOT IN(smon timer,pmon timer,rdbms ipc message,Null event,parallel query dequeue,pipe get,client message,SQL*Net message to client,SQL*Net message from client,SQL*Net more data from client,dispatcher timer,virtual circuit status,lock manager wait for remote message,PX Idle Wait,PX Deq: Execution Msg,PX Deq: Table Q Normal,wakeup time manager,slave wait,i/o slave wait,jobq slave wait,null event,gcs remote message,gcs for action,ges remote message,queue messages) ) t1,(select * from (select t.event,t.total_waits,t.total_timeouts,t.time_waited,t.average_wait,rownum num from(select event,total_waits,total_timeouts,time_waited,average_wait from v$system_event where event not in(smon timer,pmon timer,rdbms ipc message,Null event,parallel query dequeue,pipe get,client message,SQL*Net message to client,SQL*Net message from client,SQL*Net more data from client,dispatcher timer,virtual circuit status,lock manager wait for remote message,PX Idle Wait,PX Deq: Execution Msg,PX Deq: Table Q Normal,wakeup time manager,slave wait,i/o slave wait,jobq slave wait,null event,gcs remote message,gcs for action,ges remote message,queue messages)order by time_waited desc ) t) where num11) t2,(SELECT VALUE CPU FROM v$sysstat WHERE NAME LIKE CPU used by this session ) t3-oracle10gselect t2.event,round(100*t2.time_waited/(t1.w1+t3.cpu),2) event_wait_percent from (SELECT SUM(time_waited) w1 FROM v$system_event WHERE event NOT IN(smon timer,pmon timer,rdbms ipc message,Null event,parallel query dequeue,pipe get,client message,SQL*Net message to client,SQL*Net message fromclient,SQL*Net more data from client,dispatcher timer,virtual circuit status,lock manager wait for remote message,PX Idle Wait,PX Deq: Execution Msg,PXDeq: Table Q Normal,wakeup time manager,slave wait,i/o slave wait,jobq slave wait,null event,gcs remote message,gcs for action,ges remote message,queue messages,wait for unread message on broadcastchannel,PX Deq Credit: send blkd,PX Deq: Execute Reply,PX Deq: Signal ACK,PX Deque wait,PX Deq Credit: need buffer,STREAMS apply coord waiting for slavemessage,STREAMS apply slave waiting for coord message, Queue Monitor Wait, Queue Monitor Slave Wait, wakeup event for builder, wakeup event for preparer, wakeupevent for reader,wait for activate message, PX Deq: Par Recov Execute,PX Deq: Table Q Sample,STREAMS apply slave idle wait,STREAcapture process filter callback wait forruleset,STREAMS fetch slave waiting for txns,STREAMS waiting for subscribers to catch up,Queue Monitor Shutdown Wait,AQ Proxy Cleanup Wait,knlqdeq,class slave wait,master wait,DIAG idle wait,ASM background timer,KSV master wait,EMON idle wait,Streams AQ: RAC qmn coordinator idle wait,Streams AQ: qmn coordinator idle wait,Streams AQ: qmn slaveidle wait,Streams AQ: waiting for time management or cleanup tasks,Streams AQ: waiting for messages in the queue,Streams fetch slave: waiting for txns,Streams AQ:deallocate messages from Streams Pool,Streams AQ: delete acknowledged messages,LNS ASYNC archive log,LNS ASYNC dest activation,LNS ASYNC end of log,LogMiner: client waiting for transaction,LogMiner: slave waiting for activate message,LogMiner: wakeup event for builder,LogMiner: wakeup event for preparer,LogMiner: wakeup event for reader) ) t1,(select * from (select t.event,t.total_waits,t.total_timeouts,t.time_waited,t.average_wait,rownum num from(select event,total_waits,total_timeouts,time_waited,average_wait from v$system_event where event not in(smon timer,pmon timer,rdbms ipc message,Null event,parallel query dequeue,pipe get,client message,SQL*Net message to client,SQL*Net message fromclient,SQL*Net more data from client,dispatcher timer,virtual circuit status,lock manager wait for remote message,PX Idle Wait,PX Deq: Execution Msg,PXDeq: Table Q Normal,wakeup time manager,slave wait,i/o slave wait,jobq slave wait,null event,gcs remote message,gcs for action,ges remote message,queue messages,wait for unread message on broadcastchannel,PX Deq Credit: send blkd,PX Deq: Execute Reply,PX Deq: Signal ACK,PX Deque wait,PX Deq Credit: need buffer,STREAMS apply coord waiting for slavemessage,STREAMS apply slave waiting for coord message, Queue Monitor Wait, Queue Monitor Slave Wait, wakeup event for builder, wakeup event for preparer, wakeupevent for reader,wait for activate message, PX Deq: Par Recov Execute,PX Deq: Table Q Sample,STREAMS apply slave idle wait,STREAcapture process filter callback wait forruleset,STREAMS fetch slave waiting for txns,STREAMS waiting for subscribers to catch up,Queue Monitor Shutdown Wait,AQ Proxy Cleanup Wait,knlqdeq,class slave wait,master wait,DIAG idle wait,ASM background timer,KSV master wait,EMON idle wait,Streams AQ: RAC qmn coordinator idle wait,Streams AQ: qmn coordinator idle wait,Streams AQ: qmn slaveidle wait,Streams AQ: waiting for time management or cleanup tasks,Streams AQ: waiting for messages in the queue,Streams fetch slave: waiting for txns,Streams AQ:deallocate messages from Streams Pool,Streams AQ: delete acknowledged messages,LNS ASYNC archive log,LNS ASYNC dest activation,LNS ASYNC end of log,LogMiner: client waiting for transaction,LogMiner: slave waiting for activate message,LogMiner: wakeup event for builder,LogMiner: wakeup event for preparer,LogMiner: wakeup event for reader)order by time_waited desc ) t) where num11) t2,(SELECT VALUE CPU FROM v$sysstat WHERE NAME LIKE CPU used by this session ) t3-2、查询各种指标,根据各种指标反映的问题是否和等待事件有关联关系,进一步确定问题所在-9iselect a.cache_hit_percent,e.rowcache_hitratio,d.pin_ration_percent,d.get_ratio_percent,f.mem_sort_percent ,b.latch_ratio_percent from(SELECT ROUND(1-(s1.VALUE-s4.VALUE-s5.VALUE)/(s2.VALUE+s3.VALUE-s4.VALUE-s5.VALUE)*100,2) cache_hit_percent FROM v$sysstat s1, v$sysstat s2, v$sysstat s3,v$sysstat s4, v$sysstat s5 WHERE s1.NAME=physical reads AND s2.NAME=consistent getsAND s3.NAME=db block gets AND s4.NAME=physical reads direct (lob) AND s5.NAME=physical reads direct) a, (select round(100*(1-sum(misses)/sum(gets),2) latch_ratio_percent from v$latch) b,(select round(100*c.pin_RATIO/b.total,2) pin_ration_percent, round(100*(a.get_ratio/b.total),2) get_ratio_percent from (select sum(pinhitratio) pin_ratio from v$LIBRARYCACHE) c,(select sum(gethitratio) get_ratio from v$LIBRARYCACHE) a,(select count(*) total from v$LIBRARYCACHE) b) d,(select round(100*(1-sum(getmisses)/sum(gets),2) rowcache_hitratio from v$rowcache ) e,(SELECT round(100*s1.VALUE/(s2.VALUE+s1.VALUE),2) mem_sort_percent FROM v$sysstat s1 ,v$sysstat s2 WHERE s1.NAME=sorts (memory) AND s2.NAME=sorts (disk)f - 10gselect a.cache_hit_percent,e.rowcache_hitratio,d.pin_ration_percent,d.get_ratio_percent,f.mem_sort_percent ,b.latch_ratio_percent from(SELECT ROUND(1-(s1.VALUE-s4.VALUE-s5.VALUE)/(s2.VALUE+s3.VALUE-s4.VALUE-s5.VALUE)*100,2) cache_hit_percent FROM v$sysstat s1, v$sysstat s2, v$sysstat s3,v$sysstat s4, v$sysstat s5 WHERE s1.NAME=physical reads AND s2.NAME=consistent getsAND s3.NAME=db block gets AND s4.NAME=physical reads direct (lob) AND s5.NAME=physical reads direct) a, (select round(100*(1-sum(misses)/sum(gets),2) latch_ratio_percent from v$latch) b,(select round(100*c.pin_RATIO/b.total,2) pin_ration_percent, round(100*(a.get_ratio/b.total),2) get_ratio_percent from (select sum(pinhitratio) pin_ratio from v$LIBRARYCACHE) c,(select sum(gethitratio) get_ratio from v$LIBRARYCACHE) a,(select count(*) total from v$LIBRARYCACHE) b) d,(select round(100*(1-sum(getmisses)/sum(gets),2) rowcache_hitratio from v$rowcache ) e,(SELECT round(100*s1.VALUE/(s2.VALUE+s1.VALUE),2) mem_sort_percent FROM v$sysstat s1 ,v$sysstat s2 WHERE s1.NAME=sorts (memory) AND s2.NAME=sorts (disk)f-3、产看内存配置,查看内存配置是否合理(结合查询到的各种指标,初步判断内存是否合理)-9iSELECT NAME,ROUND(VALUE/1024/1024) size_M FROM v$parameter WHERE NAME IN (java_pool_size,large_pool_size,shared_pool_size,log_buffer,db_cache_size,pga_aggregate_target,sga_max_size,db_recycle_cache_size,db_keep_cache_size)ORDER BY size_m DESC;-10gselect component,current_size/1024/1024 cur_size_M ,max_size/1024/1024max_size_M from v$sga_dynamic_components - 4、查询三个top10sql语句,发现执行次数最多、内存、硬盘读取量大的sql,根据address查询在系统中的执行计划,是否需要进一步优化select 硬盘读取量最大的top |rownum t1_id,sql_disk_reads,disk_reads,address from (select sql_text sql_disk_reads ,disk_reads from v$sqlarea order by disk_reads desc)where rownum11union allselect 高速缓冲区使用最大的top |rownum t2_id ,sql_buffer_gets ,buffer_gets,address from (select sql_text sql_buffer_gets,buffer_gets from v$sqlarea order bybuffer_gets desc) where rownum11union allselect 执行次数最多的top |rownum t3_id ,sql_executions ,executions,address from (select sql_text sql_executions,executions from v$sqlarea order by executions desc)where rownum11-根据address查询在系统中的执行计划(真实执行计划),这个不同set autotrace on(这个是预执行计划,真实情况不一定,-这也是很多时候我们执行很好,但实际效率较低不得其解的原因)select lpad( , 2*(level-1)|operation| |decode(id, 0, Cost = |position) OPERATION,options, object_namefrom v$sql_planstart with (address = and id=0 ) connect by prior id = parent_id and prior address = address and prior hash_value = hash_value and prior child_number = child_number order by id, position ;-5、查询系统运行较长的sql语句,该语句能将多数的耗费资源的sql抓取到select q.sql_text,s.elapsed_seconds,s.start_time,s.opname from v$session_longops s,v$sqlarea q where s.sql_hash_value=q.hash_value order by s.ELAPSED_SECONDS desc;-根据address查询在系统中的执行计划,是否需要优化select lpad( , 2*(level-1)|operation| |decode(id, 0, Cost = |position) OPERATION,options, object_namefrom v$sql_planstart with (address = and id=0 ) connect by prior id = parent_id and prior address = address and prior hash_value = hash_value and prior child_number = child_number order by id, position ;-6、找到
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 公司借法人款合同范例
- 产业合作协议合同范例
- 04版专利实施许可合同:新能源技术创新专利应用许可
- 2024年广告投放合同协议书(效果营销)
- 2024城市智能交通信号控制系统合同
- 2024国有企业物资采购与运输协议
- 2024国际市场营销合作合同
- 2024年分包商变更与补充协议
- 热力行业总负责人聘请协议
- 公务用车管理责任分配
- 2024产学研合作框架协议
- 2023年甘肃省工程设计研究院有限责任公司招聘笔试真题
- 2024年新中国成立75周年课件
- 2022部编版道德与法治三年级下册《请到我的家乡来》教学设计
- 中国燃气招聘笔试题库2024
- 左邻右舍一家亲(教学设计)-2023-2024学年五年级上册综合实践活动蒙沪版
- 10以内连加练习题完整版51
- 华为业务增长的流程管理之道:以客户为中心的高效运营策略
- GB 30254-2024高压三相笼型异步电动机能效限定值及能效等级
- 江苏省宿迁市2024年中考物理试卷【附参考答案】
- 绿化养护考核办法及实施细则
评论
0/150
提交评论