Some Oracle 10g Tuning tips
AWR
In Oracle10g the Automatic Workload repository is the primary component of Common Manageability Infrastructure (CMI). It is the successor for the Statspack. While the Statspack is still available with 10g, just a few improvements are planned to it; therefore AWR is the preferred mechanism for diagnosing database problems.
AWR provides data used by other CMI components, such as system generated alerts and the advisors. The AWR consist of 2 main components:
- Repository snapshot.
AWR relies on MMON which wakes up every hour and statistics collection into the repository snapshot (you can modify the collection interval), AWR snapshot provides a persistent view of database statistics.
A script is provided ($ORACLE_HOME/rdbms/admin/awrrpt.sql) to generate a report using repository snapshot. There is also an awrrpti.sql report as well, which has essentially the same output but allows you to define and report on a specific instance.
ADDM
The Automatic Database Diagnostic Monitor (ADDM) uses the snapshot information of AWR to automatically identify performance problems and make recommendations to correct them. ADDM is the predecessor of the Oracle expert tool. ADDM functionality is embedded into the kernel making performance impact near negligible. ADDM analysis is performed every time an AWR snapshot is taken. in addition ADDM can automatically fix certain problems.
To allow use of ADDM, a PL/SQL interface called DBMS_ADVISOR has been provided. This interface may be called directly through the supplied script $ORACLE_HOME/rdbms/admin/addmrpt.sql. Besides this PL/SQL package a number of views allow you to retrieve the results of any actions performed with the DBMS_ADVISOR API.
When the parameter STATISTICS_LEVEL is set to TYPICAL or ALL, the database will automatically schedule the AWR to be populated every 60 min. To create snapshots out of this interval you need to use the dbms_workload_repository.create_snapshot () package.
To be useful in diagnosing a particular problem, the snapshots needs to be created before and after the situation you wish to examine.
The following views are available for querying ADDM information.
View | Description |
DBA_ADVISOR_ACTIONS | Actions associated with all recommendations |
DBA_ADVISOR_COMMANDS | Commands used by advisor in DB for specifying recommended actions |
DBA_ADVISOR_DEF_PARAMETERS | Parameters and default values for all tasks in the database. |
DBA_ADVISOR_DEFINITIONS | Properties of all the advisors in the database |
DBA_ADVISOR_DIRECTIVES | Not documented |
DBA_ADVISOR_FINDINGS | Findings discovered by all advisors |
DBA_ADVISOR_JOURNAL | Journal entries for all tasks |
DBA_ADVISOR_LOG | Current state of all tasks along with execution specific data such as progress monitoring and completion status |
DBA_ADVISOR_OBJECT_TYPES | Object types used by all advisors |
DBA_ADVISOR_OBJECTS | Objects currently referenced by all advisors |
DBA_ADVISOR_PARAMETERS | Parameters and their current value for all tasks |
DBA_ADVISOR_PARAMETERS_PROJ | Not documented |
DBA_ADVISOR_RATIONALE | Rationales for all recommendations |
DBA_ADVISOR_RECOMMENDATION | Result of complemented diagnostics tasks with action recommendation for the problems identified in each run |
DBA_ADVISOR_SQLA_REC_SUM | Recommendation rollup information for all workload objects after analysis |
DBA_ADVISOR_SQLA_WK_MAP | Workload references for all tasks |
DBA_ADVISOR_SQLA_WK_STMTS | Workload objects after analysis |
DBA_ADVISOR_SQLW_COLVOL | Not documented |
DBA_ADVISOR_SQLW_JOURNAL | Journal entries for all workload |
DBA_ADVISOR_SQLW_PARAMETERS | Workload parameters and their current values |
DBA_ADVISOR_SQLW_STMTS | Rows that correspond to all statements in the workload |
DBA_ADVISOR_SQLW_SUM | Aggregate picture of all SQL workload |
DBA_ADVISOR_SQLW_TABLES | Cross-references between workload statements and tables references on it. |
DBA_ADVISOR_SQLW_TABVOL | Not documented |
DBA_ADVISOR_SQLW_TEMPLATES | Aggregate picture of all SQL workload template objects |
DBA_ADVISOR_TASKS | Information about all tasks in the DB |
DBA_ADVISOR_TEMPLATES | Information about all templates in the DB |
DBA_ADVISOR_USAGE | Information for each type of advisor |
SQL Tuning Advisor
Analyze table customers; List chained rows; |
Then run the following query accessing the CHAINED_ROWS table to check the customer table chaining:
Select HEAD_ROWID from CHAINED_ROWS where TABLE_NAME = ‘CUSTOMER’; |
If no rows are returned, then you don’t have a chaining problem. If there is a chaining problem then the query will return the head_rowid for all chained rows. You can also use the “count(*)” against the CHAINED_ROWS table to find the number of chained rows. In V$SYSSTAT, the “table fetch continue row” is an indicator of chained rows as well.
A) Batch jobs that do not have enough total redo space to complete or are so fast that the online redo logs wrap (cycle through all the logs and start writing to the first one again) before they are archived to the offline redo logs.
B) Very long running jobs that are spending a large amount of time switching online redo logs. Long running jobs are often much faster when the entire job fits into a single online redo log. For the online transaction processing (OLTP) type of environment, smaller online redo log are usually better. Optimal online redo log switch should happen every half hour (no counting the long running batch jobs that shorten this time)
Use the query below to determinate if there is a problem, it shows the time between log switches.
SQL> l select b.recid, to_char(b.first_time,'DD-MON-YY HH:MI:SS') start_time, a.recid, to_char(a.first_time,'DD-MON-YY HH:MI:SS') end_time, round(((a.first_time - b.first_time)*25)*60,2) minutes from v$log_history a, v$log_history b where a.recid = b.recid+1 order by a.first_time a |
SQL> l 1 select a.member, b.* 2 from v$logfile a, v$log b 3* where a.group# = b.group# |
No comments:
Post a Comment