Statspack installation and Report Analysis

Source: Internet
Author: User
1. View tablespaces
Select tablespace_name, file_name from dba_data_files;
2. Create a statspack tablespace
Create tablespace perfstat datafile 'd:/Oracle/oradata/perfstat. dbf' size 500 m
The tablespace should be as big as possible.
3. Install statspack.
Run the following command in the ORACLE_HOME/rdmbs/admin/directory:
@ Spcreate. SQL
If creation fails, run @ spdrop. SQL in the same directory.
4. test:
SQL> execute statspack. Snap
PL/SQL procedure successfully completed.
SQL> execute statspack. Snap
PL/SQL procedure successfully completed.
SQL> @ spreport. SQL
Use statspack:
Sqlplus perfstat/perfstat
Exec statspack. Snap; -- collects statistics and generates a snapshot number for each operation.
-- To obtain the snapshot number, you must have more than two snapshots to generate a report.
Select snap_id, snap_time from stats $ snapshot;
@ Spreport. SQL -- enter the start snapshot number and end snapshot number to be viewed
Other related scripts s:
Spauto. SQL-use dbms_job to submit a job and collect statistics on statpack information automatically.
Sppurge. SQL-to clear statistics within a period, you must provide the start snapshot and end snapshot number.
Sptrunc. SQL-clear all statistics

Statspack report analysis:

1) Adjustment order
1. Tune the design. -- Application designers
2. Tune the application. -- application developers
3. Tune memory.
4. tune I/O.
5. Tune contention.
6. Tune the operating system.
Statspack analysis report details:
10 items that must be viewed in the statspack output result
1. Load Profile)
2. instance efficiency CTR (instance efficiency hit ratios)
3. Top 5 wait events)
4. Wait for the event (wait events)
5. latch wait
6. Top SQL)
7. instance Activity)
8. file I/O (file I/O)
9. Memory Allocation (memory allocation)
10. Buffer wait (buffer waits

1. Report header information
Database instance information, including database name, ID, version number, host, and other information.
Statspack report
DB name dB ID instance inst num release cluster host
Blissdb 4196236801 blissdb 1 9.2.0.4.0 no bliss
Snap ID snap time sessions curs/SESS comment
Begin snap: 4-6-05 17:43:32 10 3.3
End snap: 5-6 months-05 18:01:32 12 6.1
Elapsed: 18.00 (mins)
Cache sizes (end)
Buffer cache: 24 m STD block size: 8 K
Shared pool size: 48 m log Buffer: 512 K
2. Load gap
This section provides statistics for every second and every thing. It is an important part of monitoring system throughput and load changes.
Load Profile
~~~~~~~~~~~~
Per second per transaction
Redo size: 431,200.16 18,627,847.04 Z
Logical read: 4,150.76 179,312.72
Block changes: 2,252.52 97,309.00
Physical read: 23.93 1,033.56
Physical writes: 68.08 2,941.04
User cballs: 0.96 41.36
Parses: 1.12 48.44
Hard parses: 0.04 1.92
Sorts: 0.77 33.28
Logons: 0.00 0.20
Executes: 2.36 102.12
Transactions: 0.02
Redo size: the size of redo logs generated per second (in bytes), which indicates the data change frequency and whether the database task is heavy or not. In this example, a redo of around K is generated on average per second, and each transaction product generates a redo of 18 MB.
Logical reads: Logical reads generated per second. The unit is block.
Block changes: the number of block changes per second, and the number of blocks that database transactions change.
Physical reads: Average number of blocks read from the disk by the database per second.
Comparison between logical reads and physical reads: about 0.55% of logical reads lead to physical I/O. On average, each transaction executes about 0.18 million logical reads. In this example, some large transactions are executed, so a high number of reads is acceptable.
Physical writes: Average number of blocks written to the disk by the database per second.
User CILS: the number of user calls per second.
Parses and hard parses: About 1.12 resolutions per second, 4% of which are hard-resolved. The system analyzes some SQL statements every 25 seconds, which is not bad. For the optimized system, after several days of running, this column should be 0, and all SQL statements should be in the shared pool after a period of time.
Sorts: the number of sorting times generated per second.
Executes: the number of executions per second.
Transactions: the number of transactions generated per second, reflecting whether database tasks are heavy or not.
% Blocks changed per read: 54.27 recursive call %: 86.94
Rollback per transaction %: 12.00 rows per sort: 32.59
% Blocks changed per read: indicates that 46% of logical reads are used for read-only but not modifiable blocks. The system only updates 54% of blocks.
Rollback per transaction %: Percentage of transaction rollback. Calculation formula: round (User rollbacks/(user commits + User rollbacks), 4) * 100%. In this example, every 8.33 transactions cause a rollback. If the rollback rate is too high, it may indicate that the database has undergone too many invalid operations. Excessive rollback may also lead to undo block competition.
3. instance hit rate
This part is important to identify potential performance problems in Oracle in advance.
Instance efficiency percentages (target 100%)
~~~~~~~~~~~~~~~~~~~~
Buffer Nowait %: 100.00 redo Nowait %: 100.00
Buffer hit %: 99.42 in-memory sort %: 100.00
Library hit %: 98.11 soft parse %: 96.04
Execute to parse %: 52.57 latch hit %: 100.00
Parse CPU to parse elapsd %: 11.40% non-Parse CPU: 99.55
Buffer Nowait %: unwaited buffer ratio obtained in the buffer, buffer Nowait <99% description, there may be hot blocks (find the TCH of x $ BH and the cache buffers chains of V $ latch_children ).
Redo Nowait %: the ratio of unwaited buffer obtained in the redo buffer.
Buffer hit %: the hit rate of data blocks in the data buffer, usually above 90%. Otherwise, if the hit rate is less than 95%, you need to adjust the important parameter. If the hit rate is less than 90%, db_cache_size may be added, however, a large number of unselected indexes also result in a high value (a large number of DB file sequential read ). If the index of a frequently accessed column is deleted, it may cause a significant decrease in buffer hit. If an index is added, but it affects the driver sequence when Oracle selects the correct table connection, the buffer hit may increase significantly. If the hit rate changes significantly, the SQL mode needs to be changed.
In-memory sort %: Sorting rate in memory.
Library hit %: It mainly indicates the SQL hit rate in the shared area, usually more than 95%. Otherwise, you need to consider increasing the sharing pool, binding variables, and modifying cursor_sharing parameters.
Soft parse %: similar to the hit rate of SQL in the shared area. If the hit rate is less than <95%, you must consider binding. If the hit rate is lower than 80%, the SQL statement may not be reused.
Execute to parse %: the number of times a statement is executed and analyzed. In an analysis, the statement is then executed and is no longer in the system where it is executed in the same session. The ratio is 0. The formula is: Execute to parse = 100 * (1-parses/executions ). Therefore, if the system parses> executions, this ratio may be less than 0. In this example, about 2.1 times are performed for each analysis. This value <0 usually indicates that there is a problem with the shared pool setting or efficiency, resulting in repeated parsing. The reparse may be serious, or is related to snapshot. If this value is negative or extremely low, it usually indicates that the database performance is faulty.
Latch hit %: Make sure that the value is greater than 99%. Otherwise, serious performance problems may occur. For example, binding may affect this parameter.
Parse CPU to parse elapsd %: formula: parse CPU to parse elapsd % = 100 * (PARSE time CPU/parse time elapsed ). That is, parse the actual running time/(parse the actual running time + wait for resource time in parsing ). This is 11.4%, which is very low. It takes about 8.77 seconds for every CPU second to parse the wall clock time, which means it takes a lot of time to wait for a resource. If this ratio is 100%, it means that the CPU time is equal to the elapsed time without any waiting.
% Non-Parse CPU: formula: % non-Parse CPU = round (100 * 1-parse_cpu/tot_cpu), 2 ). Too low indicates that resolution consumes too much time. Compared with parse_cpu, if tot_cpu is very high, this ratio will be close to 100%. This is good, it means that most of the work executed by the computer is to execute the query, rather than to analyze the query.
4. Shared Pool statistics
Shared Pool statistics begin end
------------
Memory usage %: 60.45 62.42
% SQL with executions> 1: 81.38 78.64
% Memory for SQL w/exec> 1: 70.36 68.02
Memory usage %: Percentage of the Sharing pool in use. This number should be stable for a long time between 75% and ~ 90%. If the percentage is too low, the memory will be wasted. If this percentage is too high, components outside the Shared Pool will become aging. If the SQL statement is executed again, the SQL statement will be hard parsed. In a suitable system, the usage of the Shared Pool is between 75% and slightly lower than 90%.
% SQL with executions> 1: This is the measurement of the number of SQL statements executed more than once in the shared pool. This number must be carefully considered in a system that tends to run cyclically. In this cycle system, a set of different SQL statements are executed in part of the day relative to another part of time. In the shared pool, there will be a group of unexecuted SQL statements during observation, only because the statements to be executed are not running during observation. This number is close to 100% only when the system runs the same SQL statement group consecutively. It is shown that almost 80% of SQL statements in this shared pool run more than once in the observation window within 18 minutes. The remaining 20% of statements may already be there-the system just has no reason to execute it.
% Memory for SQL w/exec> 1: This is a measure of the memory consumption of frequently used SQL statements compared with infrequently used SQL statements. This number will be very similar to % SQL with executions> 1 in general, unless some query tasks consume irregular memory.
In a stable state, we can see about 75% ~ 85% of the Shared Pool is used. If the time window of the statspack report is large enough to cover all cycles, the percentage of SQL statements executed more than once should be close to 100%. This is a statistical number affected by the observed duration. It is expected to increase with the length of time between observations.
5. Primary wait events
Common wait events:
Oracle wait events are important bases and instructions for measuring the running status of Oracle, including idle wait events and non-idle wait events.
Timed_statistics: = true, waiting for events to be sorted by the waiting time, = false, waiting for events to be sorted by the waiting amount.
Timed_statistics = true must be set on the session during statspack operation.
The idle wait event is a task that Oracle is waiting for. When diagnosing and optimizing the database, you don't need to pay too much attention to this event. The non-idle wait event is dedicated to Oracle activities, it refers to the waiting events that occur during database tasks or application program running. We should pay attention to these waiting events when adjusting the database.
Top 5 timed events
~~~~~~~~~~~~~~~~~~ % Total
Event waits time (s) Ela time
---------------------------------------------------------------------------
DB file sequential read 22,154 259 62.14
CPU time: 49 11.67
Log File parallel write 2,439 26 6.30
DB file parallel write 400 22 5.32
SQL * Net message from dblink 4,575 15 3.71
-------------------------------------------------------------
This is an event that slows down the speed than any other event. Common wait events that affect performance:
DB file scattered read: this event is usually related to full table scan. Because full table scan is carried out in the memory, it is generally not possible to be placed in a continuous buffer, so it is distributed in the buffer cache. If the number of indexes is too large, the index is missing or the index usage is limited (optimizer_index_cost_adj can also be adjusted ). This situation may also be normal, because the full table scan may be more efficient than the index scan. When the system has these waits, you need to check whether the full table scan is necessary. If you need to scan the entire table frequently and the table is small, save the table to the keep pool. If a large table often performs full table scanning, it should be an OLAP system rather than an OLTP system.
DB file sequential read: This event indicates a large amount of waiting on a single data block. This value is too high, usually because of the bad connection sequence between tables or the use of non-selective indexes. By associating this wait with other known issues in the statspack report (for example, low-efficiency SQL statements), check to ensure that index scanning is required, make sure that the connection sequence of the Multi-Table connection is adjusted. db_cache_size can determine the frequency of the event.
DB file sequential read: This event indicates a large amount of waiting on a single data block. This value is too high, usually because of the bad connection sequence between tables or the use of non-selective indexes. By associating this wait with other known issues in the statspack report (for example, low-efficiency SQL statements), check to ensure that index scanning is required, make sure that the connection sequence of the Multi-Table connection is adjusted. db_cache_size can determine the frequency of the event.
Buffer busy wait: This wait occurs when the buffer is in a non-shared mode or is being read into the buffer. The value should not be greater than 1%. check whether it is caused by hotspot blocks (if you can use reverse indexes or smaller blocks ).
Latch free: It is often related to applications that do not have good application binding. The latch is the underlying queue mechanism (the more accurate name should be the mutex mechanism), which is used to protect the shared memory structure of the system global zone (SGA). the latch is used to prevent parallel access to the memory structure. If the locks are unavailable, a loss of the locks will be recorded. Most of the latches have failed to bind variables (database cache latches), generate duplicate locks (re-execute the allocation locks), and cache contention issues (Cache LRU chains) and cache hot data blocks (Cache chains. When the latch loss rate is higher than 0.5%, you need to adjust this problem.
Log buffer space: log buffer writes faster than lgwr writes redofile. You can increase the log file size, increase the log buffer size, or use a faster disk to write data.
Logfile switch: Usually because the archiving speed is not fast enough, you need to increase the redo log.
Log File Sync: when a user submits or rolls back data, lgwr fills session redo operations from the log buffer into the log file, and the user's process must wait until the filling is completed. Each submission occurs. If this wait event affects the database performance, you need to modify the submission frequency of the application. To reduce this wait event, you must submit more records at a time, alternatively, you can access the redo log file on different physical disks.
Wait time: the wait time includes the write and send operations of the log buffer.
6. All wait events of the database user program
Wait events for DB: blissdb instance: blissdb snaps: 4-5
-> S-second
-> CS-centisecond-100th of a second
-> MS-millisecond-1000th of a second
-> US-microsecond-000000th of a second
-> Ordered by wait time DESC, Waits DESC (idle events last)
AVG
Total wait waits
Event waits timeouts time (s) (MS)/txn
--------------------------------------------------------------------------
DB file sequential read 22,154 0 259 12 886.2
Log File parallel write 2,439 2,012 26 11 97.6
DB file parallel write 400 0 22 55 16.0
SQL * Net message from dblink 4,575 0 15 3 183.0
SQL * Net more data from dblin 64,490 0 13 0 2,579.6
Control File parallel write 416 0 5 13 16.6
DB file scattered read 456 0 5 11 18.2
Write complete waits 9 0 5 568 0.4
Control File sequential read 370 0 5 13 14.8
Log buffer space 126 0 4 34 5.0
Free buffer waits 11 1 3 313 0.4
Log File switch completion 13 0 2 188 0.5
Log File sync 90 0 1 8 3.6
Log File sequential read 10 0 0 16 0.4
Latch free 17 6 0 8 0.7
Direct path read 56 0 0 1 2.2
Direct path write 56 0 0 1 2.2
SQL * Net more data to client 173 0 0 0 6.9
SQL * Net message to dblink 4,575 0 0 0 183.0
Lgwr wait for redo copy 8 0 0 1 0.3
Log File single write 10 0 0 1 0.4
DB file single write 5 0 0 0.2
SQL * Net break/reset to clien 5 0 0 0.2
Async disk Io 15 0 0 0 0.6
SQL * Net message from client 789 0 3,290 4170 31.6
Virtual circuit status 36 36 1,082 30069 1.4
Wakeup time manager 34 34 1,034 30403 1.4
SQL * Net message to client 791 0 0 0 31.6
SQL * Net more data from clien 30 0 0 1.2
-------------------------------------------------------------
7. Wait events for the background process of the database
Background wait events for DB: blissdb instance: blissdb snaps: 4-5
-> Ordered by wait time DESC, Waits DESC (idle events last)
AVG
Total wait waits
Event waits timeouts time (s) (MS)/txn
--------------------------------------------------------------------------
Log File parallel write 2,439 2,012 26 11 97.6
DB file parallel write 400 0 22 55 16.0
Control File parallel write 406 0 5 13 16.2
Control File sequential read 258 0 4 16 10.3
DB file sequential read 19 0 1 1 51 0.8
Log buffer space 24 0 0 9 1.0
Log File sequential read 10 0 0 16 0.4
Latch free 14 6 0 9 0.6
DB file scattered read 6 0 0 14 0.2
Direct path read 56 0 0 1 2.2
Direct path write 56 0 0 1 2.2
Lgwr wait for redo copy 8 0 0 1 0.3
Log File single write 10 0 0 1 0.4
Rdbms ipc message 7,339 3,337 3,172 432 293.6
Pmon timer 373 373 1,083 2903 14.9
SMON timer 3 3 924 ##### 0.1
-------------------------------------------------------------
8. Top SQL
By adjusting the first 25 buffer read operations and the first 25 disk read operations, the system performance can be increased by 5% to 5000%.
SQL ordered by gets for DB: blissdb instance: blissdb snaps: 4-5
-> Endbuffer gets threshold: 10000
-> Note that resources reported for PL/SQL nodes des the resources used
All SQL statements called within the PL/SQL code. As individual SQL
Statements are also reported, it is possible and valid for the summed
Total % to exceed 100.
CPU elapsd
Buffer gets executions gets per exec % Total time (s) Hash Value
--------------------------------------------------------------------------
1,230,745 1 1,230,745.0 27.5 16.39 60.69
Module: PL/SQL developer
Insert into city_day_cal select * From rptuser. city_day_cal @ db15
1
143,702 1 143,702.0 3.2 1.75 18.66
Module: PL/SQL developer
Insert into city_day_cal select * From rptuser. city_day_cal @ db15
1 where curtime between to_date ('20140901', 'yyymmm') and to_date ('
200502 ', 'yyyymmm')-1
In this part of the report, the SQL statement is sorted by buffer gets, that is, the number of logical I/O executed by the SQL statement. The comment at the top shows that buffer gets is obtained by cache of a PL/SQL Unit, including the buffer gets of all SQL statements executed by this code block. Therefore, PL/SQL processes are often seen at the top of this list, because the number of separate statements executed by stored procedures is total.
SQL ordered by reads for DB: blissdb instance: blissdb snaps: 4-5
-> End disk reads threshold: 1000
CPU elapsd
Physical reads executions reads per exec % Total time (s) Hash Value
--------------------------------------------------------------------------
3,587 1 3,587.0 13.9 0.17 5.13
Module: PL/SQL developer
Select min (curtime), max (curtime) from city_day_cal
1,575 1 1,575.0 6.1 1.75 18.66
Module: PL/SQL developer
Insert into city_day_cal select * From rptuser. city_day_cal @ db15
1 where curtime between to_date ('20140901', 'yyymmm') and to_date ('
200502 ', 'yyyymmm')-1
This part sorts SQL statements through physical reading. This shows that most of the SQL statements that read the system, that is, physical I/O.
SQL ordered by executions for DB: blissdb instance: blissdb snaps: 4-5
-> End executions threshold: 100
CPU per elap per
Executions rows processed rows per exec (s) Hash Value
--------------------------------------------------------------------------
748 748 1.0 0.00 0.00 3371479671
Select T. Name, (select owner_instance from SYS. aq $ _ queue_table _
Affinities where table_objno = T. objno) from system. aq $ _ queue
_ Tables t where T. Name =: 1 and T. schema =: 2 for update skip Lo
Cked
442 1,142 2.6 0.00 0.00 1749333492
Select position #, sequence #, level #, argument, type #, charsetid, Chars
Etform, properties, nvl (length, 0), nvl (precision #, 0), nvl (scale,
0), nvl (Radix, 0), type_owner, type_name, type_subname, type_linknam
E, pls_type from argument $ where OBJ # =: 1 and procedure # =: 2 order
By sequence # DESC
This part tells us the most executed SQL statements during this period. It may be useful to isolate frequently executed queries to see if there are some methods to change the logic to avoid the need to execute these queries so frequently. Maybe a query is being executed inside a loop, and it may be executed once outside the loop. You can design simple algorithm changes to reduce the number of times that the query must be executed. Even if it runs fast, any millions of operations will start to exhaust a lot of time.
9. instance Activity
Instance activity stats for DB: blissdb instance: blissdb snaps: 4-5
Statistic total per second per Trans
CPU used by this session 4,870 4.5 194.8
CPU used when call started 4,870 4.5 194.8
Cr blocks created 45 0.0 1.8
Dbwr buffers scanned 24,589 22.8 983.6
Dbwr checkpoint buffers written 14,013 13.0 560.5
Dbwr checkpointts 5 0.0 0.2
......
Dirty buffers inspected 38,834 36.0 1,553.4 -- number of dirty Buffers
Free buffer inspected 40,463 37.5 1,618.5 -- if the number is large, the buffer is too small
......
10. I/O
The following two reports are for I/O. Generally, read and write operations on various devices are expected to be evenly distributed. Find out which files may be very "hot ". Once the DBA understands how to read and write the data, they may be able to get some performance improvements by allocating I/O evenly between disks.
Tablespace Io stats for DB: blissdb instance: blissdb snaps: 4-5
-> Ordered by IOs (reads + writes) DESC
Tablespace
AV buffer AV Buf
Reads reads/s RD (MS) blks/RD writes/s waits wt (MS)
Bliss_data
17,649 16 12.3 1.2 44,134 41 0 0.0
Undotbs1
4,484 4 9.6 1.0 29,228 27 0 0.0
System
340 0 31.0 1.1 36 0 0.0
File IO stats for DB: blissdb instance: blissdb snaps: 4-5
-> Ordered by tablespace, file
Tablespace filename
----------------------------------------------------------------------------
AV buffer AV Buf
Reads reads/s RD (MS) blks/RD writes/s waits wt (MS)
----------------------------------------------------------------------
Bliss_data D: oracleoradatablissdbbliss01.dbf
5,779 5 12.0 1.2 14,454 13 0
D: oracleoradatablissdbbliss02.dbf
5,889 5 12.1 1.2 14,772 14 0
D: oracleoradatablissdbbliss03.dbf
5,981 6 12.6 1.2 14,908 14 0
11. Buffer Pool
Buffer Pool statistics for DB: blissdb instance: blissdb snaps: 4-5
-> Standard block size pools D: Default, K: Keep, R: Recycle
-> Default pools for other block sizes: 2 K, 4 K, 8 K, 16 K, 32 K
Free write buffer
Number of cache buffer physical buffer complete busy
P buffers hit % gets reads writes waits
-----------------------------------------------------------------------
D 3,000 99.4 4,482,816 25,756 73,470 11 9 0
-------------------------------------------------------------
If we use the multi-buffer pool function, the above report will tell us the usage Fault Caused by the buffer pool. In fact, this is just a duplicate of the information we see at the beginning of the report.
12. rollback segment Activity
Instance recovery stats for DB: blissdb instance: blissdb snaps: 4-5
-> B: Begin snapshot, E: End Snapshot
Targt estd Log File log ckpt
MTTR recovery actual target size timeout Interval
(S) estd IOS redo blks
B 37 17 169 4012 3453 184320 3453
E 37 32 1385 57132 184320 184320 436361
Generally, it is expected that the activities will be evenly distributed among each rollback segment (except the system rollback segment. When you check this part of a report, the report title also has the most useful information to remember. In particular, it is recommended that Optmal be larger than AVG active when the best settings are fully used. This is the most relevant DBA activity (I/O and rollback segment information ).

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.