ba6.us - Dave's Database Related Stuff

  • home
  • blog
  • notebooks
  • projects
  • recent
  • about
  • manifesto
  • !
Home › Blogs › dmann's blog

Tag Cloud

apex Application Express Auditing data dbi development export funnies HTML Java linux monitoring oem oracle performance perl rman scripting sql SQL Developer sqlplus tuning unix windows
more tags

Search

RSS Feed

Blog Posts :

Navigation

  • Feed aggregator

User login

  • 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.
Input format
  • 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.
18 + 0 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.


Cornify
  • home
  • blog
  • notebooks
  • projects
  • recent
  • about
  • manifesto
  • !

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