ba6.us - Dave's Database Related Stuff

  • home
  • blog
  • books
  • projects
  • about
  • !
Home › Blogs › dmann's blog

Search

Tags

apex data development funnies monitoring oracle perl rman sql sqlplus unix windows
more tags

Navigation

  • Feed aggregator

Recent blog posts

  • Oracle IN Condition and Multi Column Subqueries
  • SQL For Dinosaurs
  • Quickie script to run dbv on your database...
  • Permissions for Autotrace
  • Accuracy of PROFILER.SQL from Metalink Doc: 243755.1
  • Recording Oracle System Stats for historical analysis...
  • Shell Script to Run a SQLPLUS against all databases running on a server...
  • Viewing command line args with Solaris ps utility...
  • Orion IO Test Tool
  • Documented Hints available in 11.2...
more

Books

  • What Are Books?
  • Execution Plans
  • Application Express Tips
  • Copying Databases
  • Distributed Transactions
  • Instance Differences
  • Instance Info
  • Materialized Views
  • Operating System Monitoring
  • Perl
  • Perl and Oracle
  • PL/SQL
  • Real Time Monitoring of Oracle
  • SQL Profiles
  • SQLDeveloper for Non Dummies
  • Statistics
  • Tablespace Info
  • Unix Shell Scripting
  • User Security

RSS Feed - Blog Posts

Syndicate content

User login

  • Create new account
  • Request new password

Recording Oracle System Stats for historical analysis...

dmann — Thu, 12/31/2009 - 14:27

If you are experimenting with gathering system statistics it might be helpful to archive your current settings and any intermediate settings you come up with along the way.

There is a way to save stats to a table using DBMS_STATS.CREATE_STAT_TABLE and gathering with DBMS_STATS.GATHER into that table, but the format is cryptic and it is nice to have the descriptive parameter names tagging along with the data. (In a future post I will cover format of the CREATE_STAT_TABLE format).

The current system stats info is held in the sys.aux_stats$ table. Since the format is a little wacky, I came up with the following table to hold stats and the following insert statement to populate it after every gathering of system stats.

Now you can easily query the values of old stats in the SYSTEM_STATS_HISTORY table:

-- Create a table to hold system stats info
create table SYSTEM_STATS_HISTORY as 
(SELECT PVAL2 as STATUS,
        SYSDATE as DSTART,
        SYSDATE as DSTOP,
        PVAL1 as FLAGS, 
        aux_stats$.* FROM sys.aux_stats$ WHERE 0=1);


-- To record the current system statistics, run this statement
INSERT INTO SYSTEM_STATS_HISTORY 
    SELECT (SELECT PVAL2 FROM sys.aux_stats$ where PNAME='STATUS') as STATUS,
           (SELECT PVAL2 FROM sys.aux_stats$ WHERE PNAME='DSTART') as DSTART,
           (SELECT PVAL2 FROM sys.aux_stats$ WHERE PNAME='DSTOP') as DSTOP,
           (SELECT PVAL1 FROM sys.aux_stats$ WHERE PNAME='FLAGS') as FLAGS,
           aux_stats$.*
      FROM sys.aux_stats$
     WHERE sname='SYSSTATS_MAIN'; 

And here is my favorite way to gather system stats. Specify an interval so you don't have to wait around to run a 'Stop'. Specify the interval in Minutes:

exec dbms_stats.gather_system_stats(gathering_mode => 'interval',interval => 30);
  • oracle
  • system stats
  • dmann's blog

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
2 + 9 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.


Cornify
  • home
  • blog
  • books
  • projects
  • about
  • !

Content Copyright 2006-2010. Links are copyright of respective owners.