Professional Documents
Culture Documents
net
What STATSPACK Is
Set of SQL and PL/SQL Collects performance data from v$ tables Stores collected data in separate tables Each collection of data is a snapshot Reports deltas in data between snapshots Supports ad-hoc SQL queries of the snapshot data
www.brianhitchcock.net
STATSPACK Details
Works for 8.1.7 onwards Gathers data for a single instance Snapshot levels
Snapshot interval of 15 minutes suggested Long report periods miss transient events
www.brianhitchcock.net
STATSPACK -- Good
Free (very cool!) Gathers a wide range of data
You dont know what youre looking for at first Root cause isnt usually obvious Gathers the same data on all instances Easy to share with vendors, support groups
www.brianhitchcock.net
Ocean of data Any information? Easy to get lost Shows what is happening in the instance You need to figure out if this is a problem or not
Does not tell you the solution Does not tell you that you are done tuning...
www.brianhitchcock.net
No single way to analyze output Must have history of your system Look for possible problem areas Trial and error to change problem behavior Only you can tell if you have a performance problem
www.brianhitchcock.net
Instance Summary, Efficiency Top 5 Wait Events, Wait Events SQL Ordered by Gets, Reads, Executions Instance Activity Stats Tablespace IO Stats Ordered by IOs, Tblspc-file Buffer Pool Statistics Rollback Segment Stats, Storage Latch Activity, Sleep, Miss Sources Dictionary Cache Stats Library Cache Activity SGA Memory Summary, Breakdown init.ora Parameters
www.brianhitchcock.net
Documentation of output
No comprehensive documentation
Oracle 8i Reference
Appendix A -- Wait Events defined Appendix B -- Enqueue Names defined Appendix C -- Statistics Descriptions
$ORACLE_HOME/rdbms/admin/spdoc.txt ORACLE High-Performance Tuning with STATSPACK, Donald K. Burleson, Oracle Press ISBN 0-07-213378-3 What output means for your system
No explanation of
www.brianhitchcock.net
Configuration Used
Oracle 8.1.7.2 Snapshots every 15 minutes
Default STATSPACK snapshot level Application loads and analyzes web site click stream data
Lots of data More data all the time We dont know what vendor code looks like
www.brianhitchcock.net
Actual Use
4 Performance issues in 2002
www.brianhitchcock.net
Long run interferes with next days data load STATSPACK captures SQL
Report SQL doesnt generate where clause properly to use partition pruning Vendor refuses to change their code We simply removed the reports
www.brianhitchcock.net
New vendor sets up demo, data load slow Data load runs twice as fast at vendor Statspack output doesnt show anything obvious Compare configuration of vendor and our dbs Vendor has only one redo log file per group We had two redo log files per group We drop one file per group, performance issue resolved
www.brianhitchcock.net
Data load so slow no time for daily reporting Must run faster or the data wont be loaded We dont know if this load will run faster Do we have a performance issue?
Yes, data load must run faster to be useful No, perhaps this is as fast as it can be...
www.brianhitchcock.net
www.brianhitchcock.net
Bad SQL?
SQL shouldnt cost much
Select looking for one row Table has two indexes Explain plan shows index full scan Should show index range scan Explain plan with hint to force one index Verify cost of each index Optimizer is choosing wrong index!
Indexes added by vendor to be safe...
www.brianhitchcock.net
www.brianhitchcock.net
www.brianhitchcock.net
Solution
After dropping costly index
data load time was 18 hours, became 1 hour 18:1 improvement (1800%) No idea, Oracle requested running 18 hour data load to gather instance data Business users said NO! Indexes created by vendor, no need for both indexes
Wait Events are all that matters Return to Case 3) Examine Top 5 Wait Events section Try to understand what is causing the wait time
www.brianhitchcock.net
www.brianhitchcock.net
Many wait events in STATSPACK output should be ignored (a bug perhaps? Or an RFE?) Requests the full STATSPACK report Tells me that the latch free wait event must be addressed set session_cached_cursors = 100 Performance improvement will be significant Data load now takes 19 hours (about 10% worse)
www.brianhitchcock.net
What Happened?
How could the experts miss the bad SQL? Wait events are important
In this case
10 milliseconds is 1 centisecond (cs) = 0.01 sec 27457 --> 27475 cs = 274.75 seconds Report interval was 4.60 minutes (276 seconds) confused? How many cs left until Happy Hour?
www.brianhitchcock.net
www.brianhitchcock.net
MetaLink Note:191103.1 PQ Wait Events STATSPACK report should filter out idle events Database Performance Guide and Ref 9.0.1
Explains more about this feature
www.brianhitchcock.net
<----- remove
<----- remove
www.brianhitchcock.net
Wait Time was never an issue! If you dont remove the idle events
907997/(27475+907997) = 97%
www.brianhitchcock.net
www.brianhitchcock.net
Normal 6.5 hours, Long 16 hours Varies randomly, no pattern Normal, Long Compare reports Look for differences between reports
Normal -- 11 tablespaces accessed Long -- 74 tablespaces accessed
www.brianhitchcock.net
We arent allowed to connect as oracle Cant see what they might be running (cron?) Production DBAs decided we needed full exports We werent notified Stop the exports, performance issue goes away!
Turns out
www.brianhitchcock.net
Remember when it was cool to discuss hit rates? Compute buffer cache hit ratio from tables Tables larger than physical memory Cant have all pages in memory at once Buffer cache hit ratio wont be 100% Bad SQL (index) was the real problem Buffer cache hit ratio wasnt relevant
For Case 4)
www.brianhitchcock.net
Hit Ratio
Case 4)
13 17
Snapshot Id
www.brianhitchcock.net
21
Statistic Total per Second per Trans --------------------------------- ---------------- ------------ -----------CPU used by this session 1,422,921 1,556.8 154.4 CPU used when call started 2,237,915 2,448.5 242.8 <----Top 5 Wait Events ~~~~~~~~~~~~~~~~~ Wait % Total Event Waits Time (cs) Wt Time --------------------------------------- ------------ ------------ ------PX Deq: Table Q Normal 495,566 1,017,115 30.12 <-- remove slave wait 25,580 744,985 22.06 PX Deq Credit: send blkd 406,262 678,556 20.10 <-- remove PX Deq: Execution Msg 33,009 438,309 12.98 <-- remove latch free 42,575 134,840 3.99 ------------------------------------------------------------879825 cs total time = 2237915 + 879825 = 3117740 Wait time is 879825/3117740 = 28%
www.brianhitchcock.net
Review
For the 4 issues we had, STATSPACK output
Fixed 2 issues
Provided the data that led to the root cause Verified that the fix was working
Tuning process much faster with STATSPACK Same process worked for all 4 issues Decided not to look for further improvements
Wait Time analysis might be useful...
www.brianhitchcock.net
oraperf.com Analyzer
Website oraperf.com
www.brianhitchcock.net
oraperf.com
Who or what is oraperf.com?
Oraperf.com is run by Anjo Kolk. Anjo has worked for over 16 years at Oracle (1985-2001). While at Oracle he worked in different countries and different departments. Many people generate utlbstat/utlestats and statspack reports, but don't know how to interpret the data. People that do look at these are reports also mostly looking at the wrong information and end up making the wrong tuning decisions. That is why the reports are analyzed based on the YAPP method. The YAPP method will show what component of the total response time should be tuned first. YAPP-Method -- Yet Another Performance Profiling Method http://oraperf.com/download/yapp_anjo_kolk.pdf www.brianhitchcock.net
oraperf.com -- Case 3)
Upload report from slow data load Analyzer shows
Response time
91.63% CPU Time 8.37% Wait Time
Advice?
Reduce the number of buffer gets or executions
Wait time
www.brianhitchcock.net
oraperf.com -- Case 3)
Upload report from fast data load Analyzer shows
Response time
5.16% CPU Time 94.84% Wait Time
Advice?
Tune PX Deq: Execution Msg event - But this is an idle event...
oraperf.com -- Case 3)
Conclusion
oraperf.com analyzer provides another tool for performance tuning Well worth using if only to compute
Response Time CPU Time Wait Time - Check for idle wait events...
www.brianhitchcock.net
No Excuses
Install STATSPACK Generate two snapshots Generate standard report Upload to oraperf.com Review advice Fast, free performance analysis!
www.brianhitchcock.net
Installing STATSPACK
Create separate tablespace Create PERFSTAT user Execute SQL script to create tables Setup job to execute snapshots Setup process to purge data over time Set timed_statistics = TRUE
www.brianhitchcock.net
Installing STATSPACK
As user SYS
create tablespace perfstat datafile '/xxx/xxx/perfstat_01.dbf' size 500M;
www.brianhitchcock.net
www.brianhitchcock.net
Space Used
Snapshot size varies with
Db1 21 tablespaces --> 0.15 Mb/snapshot Db2 376 tablespaces --> 0.37 Mb/snapshot Assuming a snapshot every 15 minutes
96 snapshots per day Db1 --> 14.4 Mb/day Db2 --> 35.6 Mb/day
www.brianhitchcock.net
Example
www.brianhitchcock.net
Summary
STATSPACK
Free, easy to install, easy to run Output can be very useful or confusing Real-world use has resulted in big performance gains Useful for all instances Standard way to gather performance data
www.brianhitchcock.net
www.brianhitchcock.net