ã¨ãããããstats$ãã³ãã«è¡¨ã¨ãTop 5 Timed Eventsã¨ãã®ã¬ãã¼ããè¦ããããã«ãªãã¨ããã¾ã§ã
ãªããSTATSPACK 設定手順 ãè¦ãªããããã¾ããã
ç°å¢
- Oracle Database Express Edition 11g Release 2ãCentOS 6.4 x86_64ä¸ã§åä½
æé
ã¤ã³ã¹ãã¼ã«
SQL*Plusã§SYSã§ãã°ã¤ã³ããã
$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.2.0 Production on é 9æ 20 13:59:06 2013 Copyright (c) 1982, 2011, Oracle. All rights reserved. Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production ã«æ¥ç¶ããã¾ããã SQL>
以ä¸ã®ã¹ã¯ãªãããå®è¡ãããOracleã¤ã³ã¹ãã¼ã«ãã£ã¬ã¯ããªä¸ã®ã¹ã¯ãªãããå®è¡ããã®ã§ãSQL Developerã§ãªãOracleã¤ã³ã¹ãã¼ã«ãããã·ã³ã«SSHã¨ãã§æ¥ç¶ãã¦ããSQL*Pluså®è¡ãããã¨ã«ãªãã¨æãã
éä¸ãä¸åå ¥åãæ±ããããã
@$ORACLE_HOME/rdbms/admin/spcreate.sql ï¼ä¸ç¥ï¼ Choose the PERFSTAT user's password ----------------------------------- Not specifying a password will result in the installation FAILING perfstat_passwordã«å¤ãå ¥åãã¦ãã ãã: xxxx xxxx Choose the Default tablespace for the PERFSTAT user --------------------------------------------------- Below is the list of online tablespaces in this database which can store user data. Specifying the SYSTEM tablespace for the user's default tablespace will result in the installation FAILING, as using SYSTEM for performance data is not supported. Choose the PERFSTAT users's default tablespace. This is the tablespace in which the STATSPACK tables and indexes will be created. TABLESPACE_NAME CONTENTS STATSPACK DEFAULT TABLESPACE ------------------------------ --------- ---------------------------- SYSAUX PERMANENT * USERS PERMANENT Pressing <return> will result in STATSPACK's recommended default tablespace (identified by *) being used. default_tablespaceã«å¤ãå ¥åãã¦ãã ãã: Using tablespace SYSAUX as PERFSTAT default tablespace. Choose the Temporary tablespace for the PERFSTAT user ----------------------------------------------------- Below is the list of online tablespaces in this database which can store temporary data (e.g. for sort workareas). Specifying the SYSTEM tablespace for the user's temporary tablespace will result in the installation FAILING, as using SYSTEM for workareas is not supported. Choose the PERFSTAT user's Temporary tablespace. TABLESPACE_NAME CONTENTS DB DEFAULT TEMP TABLESPACE ------------------------------ --------- -------------------------- TEMP TEMPORARY * Pressing <return> will result in the database's default Temporary tablespace (identified by *) being used. temporary_tablespaceã«å¤ãå ¥åãã¦ãã ãã: Using tablespace TEMP as PERFSTAT temporary tablespace. ... Creating PERFSTAT user ... Installing required packages ... Creating views ... Granting privileges ï¼ä¸ç¥ï¼ Creating Package STATSPACK... ããã±ã¼ã¸ã使ããã¾ããã ã¨ã©ã¼ã¯ããã¾ããã Creating Package Body STATSPACK... ããã±ã¼ã¸æ¬ä½ã使ããã¾ããã ã¨ã©ã¼ã¯ããã¾ããã NOTE: SPCPKG complete. Please check spcpkg.lis for any errors.
PERFSTATã¨ããã¦ã¼ã¶ã使ãããã®ã§ããã®ãã¹ã¯ã¼ããå ¥åããããªãããã®ã¹ãã¼ãã«stats$ã¨ããä½ãããã
perfstat_passwordã«å¤ãå ¥åãã¦ãã ãã: xxxx
PERFSTATã®è¡¨é åã鏿ãããããã©ã«ãã§ãããªã空ã§è¯ãããã®ç°å¢ã®å ´åãSYSAUXã«ãªãã
default_tablespaceã«å¤ãå ¥åãã¦ãã ãã:
ä¸æè¡¨é åã鏿ãããããã©ã«ãã§ãããªã空ã§è¯ãããã®ç°å¢ã®å ´åãTEMPã«ãªãã
temporary_tablespaceã«å¤ãå ¥åãã¦ãã ãã:
ãã®ç¶æ ã§PERFSTATã«ãã°ã¤ã³ããä¸è¨ã®ã¯ã¨ãªãå®è¡ãã¦ã¿ããä¸èº«ã¯ã«ã©ã ãstatspackã®ãã¼ãã«ã使ããã¦ãããã¨ãåããã
select * from stats$sql_summary;
çµ±è¨æ å ±ã®æ¡åæ¹æ³
statspackã®ã¹ãããã·ã§ãããæ¡åãããããã§æ¡åãããã®ããstatspackã®ä¸åä½ã¨ãªãã
statspackã®ã¦ã¼ã¶ã§Oracleã«ãã°ã¤ã³ãããããã©ã«ããªãperfstatã§ããã¹ã¯ã¼ãã¯ä¸åä¸ã®ã¹ã¯ãªããspcreate.sqlã®å®è¡ä¸ã«èªåã§æå®ãããã®ã
$ sqlplus perfstat/xxxx ï¼ä¸ç¥ï¼ SQL>
ã¹ãããã·ã§ãããæ¡åããã
SQL> execute statspack.snap PL/SQLããã·ã¼ã¸ã£ãæ£å¸¸ã«å®äºãã¾ããã
ãã®ç¶æ ã§stats$ã®å表ãè¦ã¦ã¿ãã¨ãè²ã ãªåæãã¼ã¿ã追å ããã¦ãããã¨ãåããã
select * from stats$sql_summary;
çµ±è¨æ å ±ã®ã¬ãã¼ã使
ã¹ãããã·ã§ããã®éå§ã¨çµäºãæå®ãã¦ããµããªã¼ã®ã¬ãã¼ãã使ã§ããã
ã¨ããããããµã³ãã«ã®ããã«ã¹ãããã·ã§ãããããä¸ååããããã¯åã«ãã¹ãããã·ã§ããçªå·ãéå§ã¨çµäºã§1ã¤ä»¥ä¸é¢ãã¦ããªãã¨å®è¡ã§ããªãã£ã¦ã ãã®ãã¨ã
$ sqlplus perfstat/a ï¼ä¸ç¥ï¼ SQL> execute statspack.snap PL/SQLããã·ã¼ã¸ã£ãæ£å¸¸ã«å®äºãã¾ããã
ã¬ãã¼ãã使ããã
éä¸ãä¸åå ¥åãæ±ããããã
SQL> @$ORACLE_HOME/rdbms/admin/spreport.sql Current Instance ~~~~~~~~~~~~~~~~ DB Id DB Name Inst Num Instance ----------- ------------ -------- ------------ 2706909277 XE 1 XE Instances in this Statspack schema ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DB Id Inst Num DB Name Instance Host ----------- -------- ------------ ------------ ------------ 2706909277 1 XE XE kagamihogex6 1 Using 2706909277 for database Id Using 1 for instance number Specify the number of days of snapshots to choose from ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Entering the number of days (n) will result in the most recent (n) days of snapshots being listed. Pressing <return> without specifying a number lists all completed snapshots. Listing all Completed Snapshots Snap Instance DB Name Snap Id Snap Started Level Comment ------------ ------------ --------- ----------------- ----- --------------------XE XE 1 20 9æ 2013 14:2 5 8 2 20 9æ 2013 14:3 5 9 Specify the Begin and End Snapshot Ids ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ begin_snapã«å¤ãå ¥åãã¦ãã ãã: 1 Begin Snapshot Id specified: 1 end_snapã«å¤ãå ¥åãã¦ãã ãã: 2 End Snapshot Id specified: 2 Specify the Report Name ~~~~~~~~~~~~~~~~~~~~~~~ The default report file name is sp_1_2. To use this name, press <return> to continue, otherwise enter an alternative. report_nameã«å¤ãå ¥åãã¦ãã ãã: Using the report name sp_1_2 STATSPACK report for Database DB Id Instance Inst Num Startup Time Release RAC ~~~~~~~~ ----------- ------------ -------- --------------- ----------- --- 2706909277 XE 1 20-9æ -13 11:3 11.2.0.2.0 NO 2 Host Name Platform CPUs Cores Sockets Memory (G) ~~~~ ---------------- ---------------------- ----- ----- ------- ------------ kagamihogex61 Linux x86 64-bit 2 2 1 .9 Snapshot Snap Id Snap Time Sessions Curs/Sess Comment ~~~~~~~~ ---------- ------------------ -------- --------- ------------------ Begin Snap: 1 20-9æ -13 14:28:37 25 1.6 End Snap: 2 20-9æ -13 14:39:04 26 1.6 Elapsed: 10.45 (mins) Av Act Sess: 0.0 DB time: 0.26 (mins) DB CPU: 0.25 (mins) Cache Sizes Begin End ~~~~~~~~~~~ ---------- ---------- Buffer Cache: 92M Std Block Size: 8K Shared Pool: 148M Log Buffer: 4,004K Load Profile Per Second Per Transaction Per Exec Per Call ~~~~~~~~~~~~ ------------------ ----------------- ----------- ----------- DB time(s): 0.0 3.9 0.00 0.00 DB CPU(s): 0.0 3.8 0.00 0.00 Redo size: 1,614.6 253,093.0 Logical reads: 167.4 26,244.0 Block changes: 4.0 631.3 Physical reads: 12.4 1,946.3 Physical writes: 0.3 45.0 User calls: 119.8 18,782.0 Parses: 2.3 367.0 Hard parses: 0.4 66.5 W/A MB processed: 0.1 10.1 Logons: 0.0 3.3 Executes: 5.9 931.8 Rollbacks: 0.0 0.0 Transactions: 0.0 Instance Efficiency Indicators ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Buffer Nowait %: 100.00 Redo NoWait %: 100.00 Buffer Hit %: 99.77 Optimal W/A Exec %: 100.00 Library Hit %: 84.23 Soft Parse %: 81.88 Execute to Parse %: 60.61 Latch Hit %: 100.00 Parse CPU to Parse Elapsd %: 92.22 % Non-Parse CPU: 66.99 Shared Pool Statistics Begin End ------ ------ Memory Usage %: 88.11 88.16 % SQL with executions>1: 76.55 74.95 % Memory for SQL w/exec>1: 67.69 75.89 ï¼ä»¥ä¸ç¥ï¼
ã¹ãããã·ã§ããéå§çªå·ãå ¥åããã
begin_snapã«å¤ãå ¥åãã¦ãã ãã: 1
ã¹ãããã·ã§ããçµäºçªå·ãå ¥åããã
end_snapã«å¤ãå ¥åãã¦ãã ãã: 2
åºåã¬ãã¼ãã®ãã¡ã¤ã«åãå ¥åãããããã©ã«ããªã空ã§è¯ãããã®å ´åãsp_{begin_snap}_{end_snap}.lstã¨ãªãã
report_nameã«å¤ãå ¥åãã¦ãã ãã:
ä¸ã®æ¹ã«å®è¡ãã°ãè¼ãã¦ãããã©ãSTATSPACK report forã®å¾ã«ãµããªã®ã¬ãã¼ãã表示ããã¦ãããã¾ããsp_1_2.lstã«ãåºåããã¦ããã
ã¬ãã¼ããã¡ã¤ã«ãè¦ãã¨ãstatspackã®åæä¾ã§æ¯è¼çè¯ãè¦ãInstance Efficiency Indicatorsã¨ãTop 5 Timed Eventsã¨ããããã®ãåããã
Instance Efficiency Indicators ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Buffer Nowait %: 100.00 Redo NoWait %: 100.00 Buffer Hit %: 99.77 Optimal W/A Exec %: 100.00 Library Hit %: 84.23 Soft Parse %: 81.88 Execute to Parse %: 60.61 Latch Hit %: 100.00 Parse CPU to Parse Elapsd %: 92.22 % Non-Parse CPU: 66.99 Shared Pool Statistics Begin End ------ ------ Memory Usage %: 88.11 88.16 % SQL with executions>1: 76.55 74.95 % Memory for SQL w/exec>1: 67.69 75.89 Top 5 Timed Events Avg %Total ~~~~~~~~~~~~~~~~~~ wait Call Event Waits Time (s) (ms) Time ----------------------------------------- ------------ ----------- ------ ------ CPU time 7 48.6 control file parallel write 219 5 22 33.4 direct path read 135 1 6 5.3 db file async I/O submit 5 1 109 3.7 log file parallel write 18 0 26 3.2
ãã¾ã
Linux - Oracleのstatspack取るだけのシェルスクリプト - Qiita [キータ]
ãã®ã¨ã³ããªã§æ¸ããstatspackã¹ãããã·ã§ããæ¡åã¨ã¬ãã¼ã使ãã·ã§ã«ã¹ã¯ãªããã«ã¾ã¨ãããã®ã