Decode360's Blog

          業精于勤而荒于嬉 QQ:150355677 MSN:decode360@hotmail.com

            BlogJava :: 首頁 :: 新隨筆 :: 聯系 ::  :: 管理 ::
            302 隨筆 :: 26 文章 :: 82 評論 :: 0 Trackbacks
          一、重要的腳本
          ?
          ??? 1、通過導出保存及共享數據
          ?
          ??? 有時需要將原始數據導出后,請教專業人士進行分析,可以使用spuexp.par,內容如下:
          ?
          ??? file=spuexp.dmp log=spuexp.log compress=y grants=y indexes=y rows=y constraints=y owner=PERFSTAT consistent=y
          ?
          ??? 使用一下腳本進行導出:
          ?
          ??? SQL> host exp userid=perfstat/perfstat parfile=E:\oracle\product\10.2.0\db_1\RDBMS\ADMIN\spuexp.par
          ??? ... ...
          ??? 成功終止導出, 沒有出現警告。
          ?
          ??? 在當前目錄下生成spuexp.dmp文件。
          ?
          ??? 2、刪除數據腳本
          ?
          ??? 用于刪除數據的spdrop.sql腳本主要調用了spdtab.sql和spdusr.sql兩個腳本
          ??? spdtab.sql用于刪除表和同義詞
          ??? spdusr.sql用于刪除用戶
          ?
          ?
          二、調整Statspack收集選項
          ?
          ??? Statspack有兩種類型的收集選項:級別(level)、門限(threshold)
          ?
          ??? 1、級別(level)
          ?
          ??? 一共分為三個級別,分別是0、5、10,默認是5。
          ?
          ??? ① level 0:一般性統計。包括等待事件、系統事件、系統統計、回滾段統計、行緩存、SGA、會話鎖、緩沖池統計等
          ??? ② level 5:增加SQL語句。SQL語句收集結果放在stats$sql_summary中
          ??? ③ level 10:增加子鎖存統計。將附加子鎖存入stats$lathc_children中(本級別建議在oracle support指導下進行)
          ?
          ??? 修改方式:
          ?
          ??? ① SQL> execute statspack.snap(i_snap_level=>0,modify_parameter=>'true'); --以后都修改
          ??? ② SQL> execute statspack.snap(i_snap_level=>10); --只修改本次
          ?
          ??? 2、快照門限
          ?
          ??? 門限只用于stats$sql_summary表中獲取的SQL語句。由于每個快照都會收集很多數據,每一行都代表獲取快照時數據庫中的一個SQL語句,因此stats$sql_summary很快就會成為Statspack中最大的表,所以需要加門限進行限制。
          ?
          ??? executions_th:SQL語句執行的數量(默認值100)
          ??? disk_reads_th:SQL語句執行的磁盤讀入數(默認值1000)
          ??? parse_calls_th:SQL語句執行的解析調用數量(默認值1000)
          ??? buffer_gets_th:SQL語句執行的緩沖區獲取的數量(默認值10000)
          ?
          ??? 任何一個門限值超過以上參數就會產生一條記錄。
          ?
          ??? 使用一下腳本修改門限的默認值:
          ?
          ??? SQL> execute statspack.modify_statspack_parameter(i_buffer_gets_th=>100000,i_disk_reads_th=>100000);
          ?
          ???
          ?
          三、整理分析結果
          ?
          ?
          ??? Statspack進行快照采集之后,會在stats$sysstat表中,針對每個snap生成N行數據,每一行表示當前某一項參數的值,具體的參數代碼及名稱可以使用以下腳本查詢:
          ?
          ??? SQL> select distinct statistic#,name from stats$sysstat order by 1;
          ?
          ??? statistic# name
          ??? ---------- ------------------------------------
          ?????????????0?logons cumulative
          ???????????? 1?logons current
          ????????? ?? 2?opened cursors cumulative
          ???????????? 3?opened cursors current
          ??????????? ?4?user?commits
          ??? ... ...
          ?
          ??? 1、物理讀寫IO操作:
          ?
          select sn.snap_id,
          ?????? to_char(snap_time, 'hh24:mi:ss') sp_time,
          ?????? (newreads.value - oldreads.value) reads,
          ?????? (newwrites.value - oldwrites.value) writes
          ? from stats$sysstat? oldreads,
          ?????? stats$sysstat? newreads,
          ?????? stats$sysstat? oldwrites,
          ?????? stats$sysstat? newwrites,
          ?????? stats$snapshot sn
          ?where newreads.snap_id = sn.snap_id
          ?? and newwrites.snap_id = sn.snap_id
          ?? and oldreads.snap_id = sn.snap_id - 1
          ?? and oldwrites.snap_id = sn.snap_id - 1
          ?? and oldreads.statistic# = 37
          ?? and newreads.statistic# = 37
          ?? and oldwrites.statistic# = 40
          ?? and newwrites.statistic# = 40
          ?? and (newreads.value - oldreads.value) > 0
          ?? and (newwrites.value - oldwrites.value) > 0;
          ?
          ??? 該SQL表述了在各個時間段中的IO物理讀和IO物理寫的數量,可用于分析各個時間段的峰值以及平均IO量,以減少競爭。
          ?
          ??? 2、Buffer命中率:
          ?
          select sn.snap_id,
          ?????? to_char(snap_time, 'hh24:mi:ss') sp_time,
          ?????? round(100 *
          ???????????? ((a.value - d.value) + (b.value - e.value) - (c.value - f.value))
          ?????????? / ((a.value - d.value) + (b.value - e.value))) "Buffer Hit Ratio"
          ? from stats$sysstat? a,
          ?????? stats$sysstat? b,
          ?????? stats$sysstat? c,
          ?????? stats$sysstat? d,
          ?????? stats$sysstat? e,
          ?????? stats$sysstat? f,
          ?????? stats$snapshot sn
          ?where a.snap_id = sn.snap_id
          ?? and b.snap_id = sn.snap_id
          ?? and c.snap_id = sn.snap_id
          ?? and d.snap_id = sn.snap_id - 1
          ?? and e.snap_id = sn.snap_id - 1
          ?? and f.snap_id = sn.snap_id - 1
          ?? and a.statistic# = 47
          ?? and d.statistic# = 47
          ?? and b.statistic# = 50
          ?? and e.statistic# = 50
          ?? and c.statistic# = 54
          ?? and f.statistic# = 54;
          ?
          ??? 注:Buffer Hit Ratio = (db block gets + consistent gets - physical reads) / (db block gets + consistent gets)
          ?
          ?
          ?
          ?




          -The End-

          posted on 2009-01-19 21:50 decode360-3 閱讀(217) 評論(0)  編輯  收藏 所屬分類: Oracle
          主站蜘蛛池模板: 镇赉县| 清徐县| 广东省| 拜泉县| 大兴区| 堆龙德庆县| 调兵山市| 芦山县| 临沭县| 美姑县| 三都| 寿阳县| 东光县| 肥西县| 含山县| 邳州市| 开平市| 宣恩县| 南丹县| 芦山县| 潼南县| 上虞市| 和顺县| 达拉特旗| 航空| 大厂| 巫溪县| 巢湖市| 额敏县| 宁乡县| 垦利县| 新绛县| 乐陵市| 乌拉特后旗| 滦南县| 祁阳县| 天全县| 疏勒县| 吕梁市| 泉州市| 安丘市|