0% found this document useful (0 votes)
9 views

D79236GC10 Appendix A

Uploaded by

comercial
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

D79236GC10 Appendix A

Uploaded by

comercial
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 20

A

Using Statspack

Copyright © 2014, Oracle and/or its affiliates. All rights reserved.


Objectives

After completing this lesson, you should be able to do the


following:
• Install Statspack
• Create Statspack snapshots
• Generate Statspack reports
• Identify the major sections of the Statspack report

A-2 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Introduction to Statspack

• Statspack is a set of scripts that capture and report on


performance data from within the Oracle database.
• With Statspack scripts, you can:
– Capture instance data by taking a “snapshot”
– Store snapshot data in the database in a separate schema
– Create reports between two snapshots
– Mark snapshots as baseline information
– Use the reports as part of a performance tuning method

A-3 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Statspack Scripts

• Install Statspack by using spcreate.sql.


• Collect statistics with statspack.snap.
• Automate the collection of statistics with
spauto.sql.
• Produce a report by using spreport.sql or
sprepsql.sql.
• Purge Statspack data with statspack.purge or
sppurge.sql.
• Truncate all Statspack tables with sptrunc.sql.
• Drop the Statspack repository with spdrop.sql.
• Export the Statspack repository with spexp.par.

A-4 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Installing Statspack

• Install Statspack:
– Supplying parameters as requested interactively
– Defining parameters in the session for batch mode
SQL> connect / as sysdba
SQL> define default_tablespace='SYSAUX'
SQL> define temporary_tablespace='TEMP'
SQL> define perfstat_password='erg8oiw'
SQL> @?/rdbms/admin/spcreate
SQL> undefine perfstat_password

• The spcreate.sql script creates the PERFSTAT


user to own the Statspack repository and package.

A-6 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Capturing Statspack Snapshots

• Capture a snapshot:
SQL> connect perfstat/erg8oiw
SQL> execute statspack.snap;
• Use the function to determine the snapshot number:
SQL> variable snap number;
SQL> begin :snap := statspack.snap; end;/
SQL print snap
• Automate snapshot collection:
SQL> connect perfstat/erg8oiw
SQL> @spauto

A-7 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Configuring Snapshot Data Capture

• Temporarily change a capture variable:


SQL> execute statspack.snap(i_snap_level=>6);
• Change defaults and take a snapshot:
SQL> execute statspack.snap -
(i_snap_level=>10, i_modify_parameter=>'true');

• Modify defaults without taking a snapshot:


SQL> execute statspack.modify_statspack_parameter –
(i_snap_level=>10, i_buffer_gets_th=>10000,-
i_disk_reads_th=>1000);
• Include session details in a snapshot:
SQL> execute statspack.snap(i_session_id=>3);

A-8 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Statspack Snapshot Levels

Level => Statistics captured

0 General performance
5 SQL statements

6 SQL plans and SQL plan usage

7 Segment-level statistics
10 Parent and child latches

AWR captures them all by default!

A-9 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Statspack Baselines and Purging

SQL> exec statspack.make_baseline -


2 (i_begin_snap => 45, i_end_snap => 50);

SQL> exec statspack.statspack.make_baseline(2,4,false);

SQL> exec statspack.make_baseline –


2 (to_date('31-AUG-2009 09:00','DD-MON-YYYY HH24:MI'),-
3 to_date('31-AUG-2009 12:00','DD-MON-YYYY HH24:MI'));

SQL> exec statspack.clear_baseline -


2 (to_date('13-DEC-2009 23:00','DD-MON-YYYY HH24:MI'),-
3 to_date('14-FEB-2010 02:00','DD-MON-YYYY HH24:MI'));

SQL> exec statspack.purge –


2 (i_begin_date=>to_date('01-JAN-2009','DD-MON-YYYY'),-
3 i_end_date =>to_date('02-JAN-2009','DD-MON-YYYY'),-
4 i_extended_purge=>TRUE);

A - 11 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.


Reporting with Statspack

SQL> connect perfstat/perfstat_password


SQL> @?/rdbms/admin/spreport

SQL> connect perfstat/perfstat_password


SQL> define begin_snap=1
SQL> define end_snap=2
SQL> define report_name=batch_run
SQL> @?/rdbms/admin/spreport

SQL> connect perfstat/perfstat_password


SQL> define begin_snap=39
SQL> define end_snap=40
SQL> define hash_value=1988538571
SQL> define report_name=batch_sql_run
SQL> @sprepsql

A - 13 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.


Statspack Considerations

• Set STATISICS_LEVEL = TYPICAL.


• Set TIMED_STATISTICS = TRUE to collect timing
information.
• Avoid overlap between Statspack and AWR.
• Choose a sensible snapshot interval.
• Fix interval when “#######” appears in the report
output.
• Gather optimizer statistics on the PERFSTAT schema.

A - 14 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.


Statspack and AWR Reports

The Statspack and AWR reports are designed to be used top


down.
• The first few pages contain the following:
– Summary Information
– Load Profile (useful with baseline)
– Instance Efficiency (useful with baseline)
– Top 10 Foreground Events
– Time Model
• The following pages show detailed data:
– SQL
– IO
– Wait Statistics

A - 16 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.


Reading an Statspack or AWR Report

• Start with the summary data at the top.


– Top 10 Foreground Events
– Wait Events and Background Wait Events
– Wait Event Histogram
– Load Profile (useful with baseline)
– Instance Efficiency (useful with baseline)
– Time Model
• Drill down to specific sections.
– Indicated by top wait events

A - 17 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.


Statspack/AWR Report Drilldown Sections
Drilldown Section
LC Shared Pool Statistics
CPU Host CPU
CPU Instance CPU
MEM Virtual Memory Paging
CPU SQL ordered by CPU
IO SQL ordered by Elapsed
CPU SQL ordered by Gets
IO SQL ordered by Reads
LC SQL ordered by Parse Calls
CONT: Block contention LC: Library cache
CPU: CPU consumption MEM: Memory consumption
ENQ: Enqueue PGAM: PGA memory consumption
IO: IO consumption RBS: Rollback segment
LAT: Latch contention UNDO: Automatic undo
SP: Shared pool

A - 18 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.


Report Drilldown Examples

• If the top timed event is related to I/O waits, look at:


– SQL ordered by Reads
– SQL ordered by Elapsed
– Tablespace IO Stats
– File IO Stats
– File IO Histogram
• If the top timed event is related to CPU usage, look at:
– Load Profile
– Time Model
– SQL ordered by CPU
– SQL ordered by Gets

A - 20 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.


Load Profile Section

• Allows characterization
of the application
• Can point toward
potential problems:
– High hard parse rate
– High I/O rate
– High login rate
• Is more useful if you have a comparable baseline
• Answers “What has changed?”
– Txn/sec change implies changed workload.
– Redo size/txn implies changed transaction mix.
– Physical reads/txn implies changed SQL or plan.

A - 21 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.


Time Model Section

The Time Model section lists a set of statistics. It:


• Gives an overview of where time is spent inside the Oracle
Database server
• Is reported from the
V$SYS_TIME_MODEL
view
• Gauges the
performance impact of
any entity of the
database, and
provides drilldown

A - 22 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.


Statspack and AWR

Statspack AWR
schema tables

Migration

Old application code


using the Statspack
schema

A - 23 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.


Summary

In this lesson, you should have learned how to:


• Install Statspack
• Create Statspack snapshots
• Generate Statspack reports
• Identify the major sections of the Statspack report

A - 24 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.


Practice Overview:
Use Statspack
This practice covers the following topics:
• Installing Statspack
• Creating Statspack snapshots
• Generating Statspack reports

A - 25 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.

You might also like