statspack安裝記
1、 安裝statspack
包都在oraclehome/rdbms/admin裡
Cmd
Sqlplus / as sysdba;
@D:oracleproduct
輸入perfstat的密碼
定義預設表空間 (如直接回車用temp,沒有temp會自己建)
定義臨時表空間 (如直接回車用temp,沒有temp會自己建)
SQL> Rem cdialeri
SQL> Rem cdialeri
SQL> Rem cgervasi
SQL> Rem cmlim
SQL> Rem gwood.uk 02/30/94 - Modified
SQL> Rem densor.uk
SQL> Rem cellis.uk
SQL> Rem
SQL>
SQL> set echo off;
Creating Package STATSPACK...
程式包已建立。
沒有錯誤。
Creating Package Body STATSPACK...
程式包體已建立。
沒有錯誤。
NOTE:
SPCPKG complete. Please check spcpkg.lis for any errors.
2.建立snap
Once you have installed Statspack the simplest way to collect a ‘snapshot’ of performance data is by executing the snap function from the Statspack package.
SQL> execute statspack.snap;
PL/SQL procedure successfully completed
SQL>
The example below will capture session level statistics for the session with a session id
(Oracle sid) of 32.
SQL> execute statspack.snap(i_session_id=>32);
It is recommended to set the parameter timed_statistics to true for your instance, as setting this parameter provides timing data which is invaluable for performance tuning, more than outweighing any additional overhead.
3:獲取報告
以perfstat連進去
sqlplus perfstat/abc123;
SQL> @D:oracleproduct
Current Instance
~~~~~~~~~~~~~~~~
DB Id DB Name Inst Num Instance
----------- ------------ -------- ------------
1174867431 ORCL 1 orcl
Instances in this Statspack schema
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DB Id Inst Num DB Name Instance Host
----------- -------- ------------ ------------ ------------
1174867431 1 ORCL orcl CCCGW
Using 1174867431 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
specifying a number lists all completed snapshots.
Listing all Completed Snapshots
Snap
Instance DB Name Snap Id Snap Started Level Comment
------------ ------------ --------- ----------------- ----- -------------------
orcl ORCL 1 22 2月 2008 09:0 5
9
11 22 2月 2008 09:1 5
7
Specify the Begin and End Snapshot Ids
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
輸入 begin_snap 的值: 1
Begin Snapshot Id specified: 1
輸入 end_snap 的值: 11
Specify the Report Name
~~~~~~~~~~~~~~~~~~~~~~~
The default report file name is sp_1_11. To use this name,
press
輸入 report_name 的值:
之後就會顯示結果。
自動SNAP:
SQL> @D:oracleproduct
PL/SQL 過程已成功完成。
Job number for automated statistics collection for this instance
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Note that this job number is needed when modifying or removing
the job:
JOBNO
----------
21
Job queue process
~~~~~~~~~~~~~~~~~
Below is the current setting of the job_queue_processes init.ora
parameter - the value for this parameter must be greater
than 0 to use automatic statistics gathering:
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
job_queue_processes integer 1
Next scheduled run
~~~~~~~~~~~~~~~~~~
The next scheduled run for this job is:
JOB NEXT_DATE NEXT_SEC
---------- -------------- ----------------
21 22-2月 -08 15:00:00
SQL>
停止自動SNAP:
SQL> execute dbms_job.remove (21);
PL/SQL 過程已成功完成。
附註:
1、statspack相關sql作用
2、Statspack 相關引數設定:
Parameter Valid Values Default Value Meaning
i_snap_level 0, 5, 10 5 Snapshot level
i_ucomment text blank Comment to be stored with snapshot
i_executions_th integer >=0 50 SQL threshold: number of executions
i_disk_reads_th integer >=0 1,000 SQL threshold: number of disk reads
i_parse_calls_th integer >=0 1,000 SQL threshold: number of parse calls
i_buffer_gets_th integer >=0 10,000 SQL threshold: number of buffer gets
i_session_id valid SID from v$session 0 (no session) Session ID; capture session granular statistics
i_modify_parameter true, false true Save specified parameters for future snapshots
案例:
To change the parameters,simply specify the new defaults that Statspack should use. To save your new parameter values permanently, use statspack.snap to set the i_modify_parameter input variable to true; this will save the new values in the stats$statspack_parameter table, as
follows:
SQL> execute statspack.snap (i_snap_level=>10, i_modify_parameter=> ‘true’);
Alternatively, you can change the defaults without taking a snapshot immediately, using the statspack.modify_statspack_parameter procedure. For example, to change the snapshot level to 10 and the SQL thresholds for buffer_gets and disk_reads without actually taking a snapshot, issue the following statement:
SQL> execute statspack.modify_statspack_parameter (i_snap_level=>10, i_buffer_gets_th=>1000, i_disk_reads_th=>1000);
3、自動SNAP相關說明:
You can use d b m s _ j o b to automate statistics collection. The file s t a t s a u t o . s q l contains an
example of how to do this, scheduling a snapshot every hour. When you create a job by using d b m s _ j o b, Oracle assigns the job a unique number that you can use for changing or removing the job. In order to use d b m s _ j o b to schedule snapshots automatically, you must set the j o b _ q u e u e _ p r o c e s s e s initialization parameter to greater than
# Set to enable the job-queue process to start. This allows dbms_job
# to schedule automatic statistics collection, using Statspack
Alter system set job_queue_processes=1
Change the interval of statistics collection by using the dbms_job.interval procedure:
execute dbms_job.interval(
In this case, ‘SYSDATE+(1/48)’ causes the statistics to be gathered each 1/48 day—every half hour. To stop and remove the automatic-collection job:
execute dbms_job.remove(
After a STATSPACK session you want to remove the STATSPACK tables.
sqlplus "/ as sysdba"
SQL> @?/rdbms/admin/spdrop.sql
SQL> drop tablespace statspack including contents and datafiles;
找出可用的SNAP:
select name,snap_id,to_char(snap_time,'DD.MM.YYYY:HH24:MI:SS')"Date/Time" from stats$snapshot,v$database;
SQL ordered by Gets
Here you will find the most CPU-Time consuming SQL statements
SQL ordered by Gets DB/Inst: AKI1/AKI1 Snaps: 5-6
-> Resources reported for PL/SQL code includes the resources used by all SQL
statements called by the code.
-> End Buffer Gets Threshold: 10000 Total Buffer Gets: 720,588
-> Captured SQL accounts for 3.1% of Total Buffer Gets
-> SQL reported below exceeded 1.0% of Total Buffer Gets
CPU Elapsd Old
Buffer Gets Executions Gets per Exec %Total Time (s) Time (s) Hash Value
--------------- ------------ -------------- ------ -------- --------- ----------
16,926 1 16,926.0 2.3 2.36 3.46 1279400914
Module: SQL*Plus
create table test as select * from all_objects
Generate Execution Plan for given SQL statement
If you have identified one or more problematic SQL statement, you may want to check the execution plan.
Remember the "Old Hash Value" from the report above (1279400914), then execute the scrip to generate the
execution plan.
sqlplus perfstat/perfstat
SQL> @?/rdbms/admin/sprepsql.sql
Enter the Hash Value, in this example: 1279400914
SQL Text
~~~~~~~~
create table test as select * from all_objects
Known Optimizer Plan(s) for this Old Hash Value
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Shows all known Optimizer Plans for this database instance, and the Snap Id's
they were first found in the shared pool. A Plan Hash Value will appear
multiple times if the cost has changed
-> ordered by Snap Id
First First Plan
Snap Id Snap Time Hash Value Cost
--------- --------------- ------------ ----------
6 14 Nov 04 11:26 1386862634 52
Plans in shared pool between Begin and End Snap Ids
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/668365/viewspace-999824/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Statspack之三-安裝statspack
- 【statspack安裝】
- 【STATSPACK】Statspack安裝、測試與使用
- statspack安裝與使用
- statspack的安裝配置
- 【實驗】【STATSPACK】Statspack 安裝、測試與使用
- Statspack之四-測試安裝好的Statspack
- STATSPACK 安裝(OCM複習)
- oracle statspack 安裝詳解---03Oracle
- statspack安裝使用和report分析
- statspack安裝使用 和 report 分析
- oracle10g statspack--安裝Oracle
- STATSPACK安裝過程中遇到的問題
- statspack 安裝以及相關引數說明
- Statspack初步學和用第一篇 安裝初步
- 【筆記】statspack 學習(一)筆記
- 轉自君三思大仙兒的statspack安裝,使用簡介
- mysql安裝記MySql
- Statspack之一-Statspack簡介
- 【安裝】安裝centos79的筆記CentOS筆記
- Manjaro安裝筆記JAR筆記
- Docker安裝記錄Docker
- lepus安裝記錄
- laravel安裝筆記Laravel筆記
- postgis安裝手記
- ZooKeeper安裝筆記筆記
- HandlerSocket安裝記錄
- Mantis安裝記錄
- MHA安裝手記
- 【筆記】statspack 學習(二) sql調整筆記SQL
- 【筆記】statspack(三) report分析 摘錄筆記
- statspack分析
- statspack解析
- 記錄 Ubuntu 安裝 homestaedUbuntu
- 安裝PHP ImageMagick筆記PHP筆記
- Ubuntu安裝docker筆記UbuntuDocker筆記
- Redis On Windows安裝記錄RedisWindows
- Macbook安裝Cplex記錄Mac