转 oracle 监控执行计划突然变化
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了转 oracle 监控执行计划突然变化,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2754字,纯文字阅读大概需要4分钟。
内容图文
![转 oracle 监控执行计划突然变化](/upload/InfoBanner/zyjiaocheng/907/09c6a5cf372e4c8f8e220d3aba3f337c.jpg)
转
http://www.oracle-wiki.net/startscriptsplanmonitor
A Script to Monitor Plan Changes Oracle Database???Script Library?? A Script to Monitor Plan Changes
Description
The following script can be used monitor and alert on plan changes. Details of its use can be found in the headers of the script.
Plan_Change_Alert.ksh
#!/bin/ksh -x
############################################################################
#
# Author : Mark Ramsay
#
# History Date Name Reason
# ---- ---- ------
# 18 May 2011 Mark Ramsay Version 1.
#
# Description
#
# This script generates a report that shows if a SQL Plan has changed
# for a given SQL ID. It is useful for tracking plans for stubborn pieces
# of SQL that may have a few good plans and the occasional bad plan.
#
# The range of dates can be changed by setting SDS_range. However,
# this script would normally be scheduled each day the range will therefore
# be 1. i.e. Changes in the last 24hrs
#
# The user should set the variable SDS_sqlid to the SQLID that is being
# monitored. The variable SDS_hash_values should be set to the
# plan_hash_values that are acceptable for the given SQLID.
#
# If a new plan_hash_value is generated for the given SQLID, then
# the script will highlight this in the report.
#
# The report can then be mailed out to individuals to look into the plan
# change.
#
############################################################################
#
# Define Variables
#
export ORACLE_SID=MYSID
export ORACLE_HOME=$(grep ^$ORACLE_SID: /var/opt/oracle/oratab |awk -F\: '{print $2}')
export ORACLE_BASE=/u01/app/oracle
export PATH=.:/usr/local/bin:/bin:/usr/sbin:/usr/bin:$ORACLE_HOME/bin
SDS_date=`/bin/date '+%e_%B_%Y'|sed -e 's/ //'`
SDS_sqlid="'SQLID1','SQLID2'"
SDS_hash_values="HASH1,HASH2"
SDS_mail_addr=myemail@mydomain.com
SDS_range=1
SDS_output=`$ORACLE_HOME/bin/sqlplus -s '/ as sysdba' <<EOF
set pagesize 0
set feedback off
set linesize 128
set heading off
set echo off
SELECT distinct PLAN_HASH_VALUE
FROM dba_hist_sqlstat q,
(
SELECT /*+ NO_MERGE */ MIN(snap_id) min_snap, MAX(snap_id) max_snap
FROM dba_hist_snapshot ss
WHERE ss.begin_interval_time BETWEEN (SYSDATE - $SDS_range) AND SYSDATE
) s
WHERE q.snap_id BETWEEN s.min_snap AND s.max_snap
AND q.sql_id IN ( $SDS_sqlid)
AND q.plan_hash_value not in
($SDS_hash_values)
/
exit;
EOF`
if [ -z "$SDS_output" ];
then
echo "All,
Explain Plan Change for SQLIDs: $SDS_sqlid - No
Regards
" | mailx -s "Explain Plan Alert Report $SDS_date" $SDS_mail_addr
else
echo "All,
Explain Plan Change for SQLIDs: $SDS_sqlid - Yes
DBA to investigate.
Plan Hash Values: $SDS_output
Regards
" | mailx -s "Explain Plan Alert Report $SDS_date" $SDS_mail_addr
fi
exit 0
dba_hist_snapshotdba_hist_sqlstatkshplanscripttuning
内容总结
以上是互联网集市为您收集整理的转 oracle 监控执行计划突然变化全部内容,希望文章能够帮你解决转 oracle 监控执行计划突然变化所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。