Professional Documents
Culture Documents
Welcome to the DBA world. Like the electric company, no one calls to say hey, all is great!. No, its usually the database is slow and .... Yes, that phone call (or now really its an email with half the company cc:d). And besides the validity of your backups, your response to this kind of problem will greatly affect your career success. First the adjective slow is relative slow compared to what? Maybe its a report. Good, because we can easily compare last week's run of REPORT245 and today's run. It ran it 30 minutes last time, this time its 45 minutes. And if you have a 35 minute SLA for this report, it really does matter, and we need to figure out the cause. But what if the user says, 'well, the online query is slower than last time I ran it last month'. This problem is a lot more vague. And before you put this in the 'I will get to this next week', maybe you need to see who he user is and if there are a lot of other users who may be using the online query. Fixing this now, may eliminate a big fix next week or while there are other issues like backups, space, or an upgrade. So, we need to look at a DB, the SQL, and the environment 'now' and 'before'. How do we do this? Starting with 10g, DBAs can use AWR, a wonderful new feature providing up-to-the-second statistics, as well as persistent statistics about every aspect of the database.
9i - improved STATSPACK
In 9i, the whole structure was improved. Also more WAIT events were exposed and documented. Therefore, the DBA would use the WAIT info for tuning. Now INTERNET sites would review your report and give you their analysis of the details. And other sites gave general hints, tips, etc. But still the architecture was still anything but automatic. The snap procedure calls need to be done as CRON jobs and the DBA needs to prune or truncate the PERFSTAT tables from time to time.
workload repository is stored in the WR schema: WRM$ tables store metadata information WRH$ tables store historical data or snapshots WRH$ tables store information for the advisory functions
As a DBA you look at BEGIN_INTERVAL_TIME for the beginning time of the snapshot and END_INTERVAL_TIME for the end time. Then you use SNAP_ID to join to the other hist views, such as: DBA_HIST_SQLSTAT DBA_HIST_WAITSTAT (and 30+ more) The snapshot represents the start/stop of a stats-gather run against the DB. What is created is a set of performance statistics captured by the workload repository at a certain time. By default it is captured automatically every 60 minutes, therefore there is a new snapshot every 60 minutes, with a SNAP_ID of 20, 21, because the snapshots are uniquely identified by an identifier SNAP_ID. The stats-gather run collects all types of DB info. The data is organized into the following categories: File statistics, general system statistics concurrency statistics instance tuning statistics SQL statistics Segment Statistics Undo Statistics Time-model statistics, Recovery Statistics RAC statistics
The DBA can change the interval parameter using this package. It sets the time interval, in minutes, between the snapshots. The default interval between snapshots is 60 minutes. The valid range of values for this parameter is 10 to 52560000 (100 years)
The DBA can also change the retention time. The package sets the period, in minutes. The default value for this parameter is 10080 (7 days). The valid range of values for this parameter is 10 minutes to 52560000 (100 years) Example - change retention to 30 days and snapshot interval to 30 minutes
BEGIN DBMS_WORKLOAD_REPOSITORY.modify_snapshot_settings( retention => 43200, -- ( = 30 Days ) ( exiting value retained if NULL) interval => 30); -- ( = 30 min ) END;
The current settings for AWR retention and interval parameters can be viewed using dba_hist_wr_control data dictionary view
select extract( day from snap_interval ) * (24 * 60) + extract( hour from snap_interval ) * 60 + extract( minute from snap_interval ) snapintmins, ( extract( day from retention ) * (24 * 60) + extract( hour from retention ) * 60 + extract( minute from retention ) ) / (60 * 24) retenintdays from dba_hist_wr_control /
OUTPUT Interval
Index Name -----------------------------I_IDL_UB11 I_TYPE2 I_USER2 I_IDL_UB21 I_OBJ4 I_IND1 I_LINK1 I_SUM$_1 I_OBJ#_INTCOL# I_OBJ1 MGMT_TARGETS_PK
Disk Reads -----3,930 2,481 2,344 1,362 1,100 886 876 876 566 554 451
Proc-ed Rows ----------6,808 0 2,093 3,828 948 948 946 946 25,263 10,366 0