How to know the optimizer mode for an SQL statement.
Hi All,
I would like to know in which optimizer mode my sqls are being processed.
Here are my DB details:
1. Optimizer mode in init.ora has been set to CHOOSE.
2. I am not using any hints in my sql statements.
3. Out of 700 tables in my database, I have analyzed only 10 tables, which are the main tables.
My observations:
1. I am aware that even one table has statistics in the sql statement the oracle chooses the COST mode.
2. When I queried my v$sql view with the column OPTIMIZER_MODE and count(*) at one point of time, I got this info
4986 records with CHOOSE,
2994 records with NONE
278 records with RULE.
What is the 'NONE' optimizer mode. And when quered all the records in the CHOOSE, the sql's are the user given sqls.
And also when I queried the records with RULE, they are all system generated sqls.
My questions:
1. When the value of the OPTIMIZER_MODE is in CHOOSE, I would like to know whether it has choosen CBO or RBO.
2. With the above info from v$sql, doest it mean that none of sqls are using RULE and all of them are using CBO?
3. Now I want to analyze all my tables, After this, I would like to know the difference after and before this.
Plese clarify me on the above three questions.
Thanks and Regards
Venu.K
Re: How to know the optimizer mode for an SQL statement.
Quote:
Originally posted by V6163
3. Out of 700 tables in my database, I have analyzed only 10 tables, which are the main tables.
You have to analyze all USER tables and indexes in your database. You can do this using
Code:
execute dbms_utility.analyze_schema('SCHEMA_NAME', 'COMPUTE');
This will enable the database engine when using the COST based optimizer to get accurate statistics to choose the best plan. This is with reference to what you mentioned about the Cost based optimizer being used when even one table is analyzed in a query (All tables in the query must be analyzed).
HTH.