 |
|
Analyze fixed object statistics
Oracle Database Tips by Donald BurlesonSeptember 16, 2015
|
See my notes on fixed object statistics for additional details.
Question: What are the Oracle fixed objects, and why do we need to execute the dbms_stats procedure gather_fixed_object_stats to analyze these fixed objects? How can analyzing the fixed objects improve SQL execution plans and SQL performance? I don't see the relationship between the v$ views and the x$ fixed tables and the execution of SQL. Why is there a need to analyze fixed objects?
Answer: The x$ fixed objects are the base tables upon which the v$ views are created.
In an Oracle instance, Oracle will supply default statistics for the x$ fixed tables if they have not been analyzed.
This one-size-fits-all solution will not always provide the optimizer with the information to generate an opttimal execution plan and Oracle strongly recommends that you run dbms_gather_fixed_object_stats:
"The Optimizer uses predefined default values for the statistics if they are missing.
These defaults may not be representative and could potentially lead to a suboptimal execution plan, which could cause severe performance problems in your system. It is for this reason that we strong recommend you gather fixed objects statistics.
Fixed Object statistics must be manually gathered. They are not created or maintained by the automatic statistics gathering job.
You can collect statistics on fixed objects using DBMS_STATS.GATHER_FIXED_OBJECTS_STATS."
BEGIN
DBMS_STATS.GATHER_FIXED_OBJECTS_STATS;
END;
Fixed Objects Statistics Considerations [MOSC ID 798257.1] suggests why those statistics are needed:
1. Missing or bad statistics on the X$ / fixed tables can lead to SQL performance degradation or hangings. Various X$ views are protected by latches and as a result can be very expensive to query in large / busy systems.
2. Most commonly this performance issue is seen on the underlying X$ tables for DBA_EXTENTS, V$ACCESS, V$RMAN_BACKUP_JOB_DETAILS, and V$RMAN_STATUS,
but any fixed table protected through latching can experience these issues.
3. Another commonly seen symptom is extreme TEMP space usage driven by poor SQL execution plans against the fixed tables.
4. RMAN, Data Guard, Streams, and Grid Control make heavy usage of the fixed tables through the DBA/V$ views and so can often bear the brunt of performance issues.
When to gather fixed object statistics
Because the fix object statistics need to represent the system during "typical" processing, and_why Oracle recommends that you run dbms_stats.gather_fixed_object_stats during peak processing times for each distinct workload on your database (you may have a bi-modal database with a day-mode and a night-mode) and you will want to export and save multiple fixed table statistics for each workload.
Oracle also recommends that you gather fix statistics during any of the following database changes:
- Increase SGA size
- Make major application changes
- Perform a database of application upgrade
How to tell when you last analyzed fixed tables
The following query will tell you if yoou have analyzed fixed object statistics:
SELECT
TABLE_NAME,
LAST_ANALYZED
FROM
DBA_TAB_STATISTICS
WHERE OWNER = 'SYS' AND TABLE_NAME LIKE 'X$%'
ORDER BY LAST_ANALYZED ASC;
References: MOSC note 272479.1: Gathering Statistics For All fixed Objects In The Data Dictionary.
|