Tuning options while using RBO [message #580721] |
Wed, 27 March 2013 05:35 |
|
sysdba007
Messages: 28 Registered: November 2012
|
Junior Member |
|
|
Hello
I am working on an assignement where client is using Oracle 10g but stuck to using RBO
Now the application team, from the GUI available to them build dynamic queries and some of them run very slow
Neither the code can not be changed to tune the queries nor do we get the exact step in the plan which is an issue (being RBO)
Fewer times we have executed SQL Tuning advisor on the selected queries and implemented the SQL profiles suggested which resolved issue for some of the queries
For some long running queries the Tuning advisor is not producing any recommendations
Another hurdle is that all the application users are using same application user id so we can not write a logon trigger to use CBO for some particular queries to see what is happening in the background!
Is there any other mechanism apart from this "SQL Tuning Advisor + SQL Profile" option in situation described above?
Thanks and Regards
sysdba007
|
|
|
|
|
|
|
|
Re: Tuning options while using RBO [message #580799 is a reply to message #580797] |
Thu, 28 March 2013 05:27 |
|
Michel Cadot
Messages: 68728 Registered: March 2007 Location: Saint-Maur, France, https...
|
Senior Member Account Moderator |
|
|
I still don't understand what are your prerequisite and requirements.
Are you or not stuck with RBO? This means does RBO be mandatory be used or not?
If yes, use the rules for RBO optimization.
If not, then then gather statistics and let Oracle optimizer does its job.
Regards
Michel
[Updated on: Thu, 28 March 2013 05:27] Report message to a moderator
|
|
|
|
|
|
Re: Tuning options while using RBO [message #581881 is a reply to message #580721] |
Thu, 11 April 2013 10:08 |
|
sysdba007
Messages: 28 Registered: November 2012
|
Junior Member |
|
|
Hello
As mentioned above we have database with RBO as optimizer and want to force {rather pursuade } queries to use CBO
I was trying to build a test case as following
The results show that creating sql profile manually shows some execution statistics details as in CBO but still did not used CBO
Am I missing something?
[1]
create table x as select * from dba_objects;
Table created
[2]
select /* pszope_txt */ object_name from x where object_id>12001 and object_id<12007;
no rows selected
[3]
select sql_text,sql_id from v$sql where sql_text like '%pszope_txt%';
select sql_id from v$sql where sql_text like '%pszope_txt%'
2a2y94xzw8y84
select /* pszope_txt */ object_name from x where object_id>12001 and object_id<12007
0vk9qn0z3gkwr
[4]
declare
sqltxt varchar2(4000);
begin
select sql_text into sqltxt from v$sql where sql_id='0vk9qn0z3gkwr';
dbms_sqltune.import_sql_profile(sql_text =>sqltxt, profile =>sqlprof_attr('OPT_PARAM(@"SEL$1" X@SEL$1 "OPTIMIZER_MODE,FIRST_ROWS_10")'),name =>'0vk9qn0z3gkwr', force_match => true);
end;
/
[5] Following are the results which show that creating sql profile manually shows some execution statistics details as in CBO but still did not used CBO
(in fact same PHV as well)
Am I missing anything in this? -> sqlprof_attr('OPT_PARAM(@"SEL$1" X@SEL$1 "OPTIMIZER_MODE,FIRST_ROWS_10")')
Honestly speaking even if I am able to force a query to use CBO at least once I shall get the bottleneck or time/resource consuming step to work upon
(1) Execution plan details Before SQL Profile was created
(2) Execution plan details After SQL Profile was created
(1)
********************************************************************************************
Before SQL Profile was created
********************************************************************************************
SQL> select * from table(dbms_xplan.display_cursor('0vk9qn0z3gkwr',null,'ADVANCED'));
PLAN_TABLE_OUTPUT
-----------------------------------------------------------------------
SQL_ID 0vk9qn0z3gkwr, child number 0
-------------------------------------
select /* pszope_txt */ object_name from x where object_id>12001 and
object_id<12007
Plan hash value: 1157146653
----------------------------------
| Id | Operation | Name |
----------------------------------
| 0 | SELECT STATEMENT | |
PLAN_TABLE_OUTPUT
-----------------------------------------------------------------------
|* 1 | TABLE ACCESS FULL| X |
----------------------------------
Query Block Name / Object Alias (identified by operation id):
-------------------------------------------------------------
1 - SEL$1 / X@SEL$1
Outline Data
-------------
PLAN_TABLE_OUTPUT
-----------------------------------------------------------------------
/*+
BEGIN_OUTLINE_DATA
IGNORE_OPTIM_EMBEDDED_HINTS
OPTIMIZER_FEATURES_ENABLE('10.2.0.3')
OPT_PARAM('optimizer_index_cost_adj' 1)
OPT_PARAM('optimizer_index_caching' 100)
RBO_OUTLINE
OUTLINE_LEAF(@"SEL$1")
FULL(@"SEL$1" "X"@"SEL$1")
END_OUTLINE_DATA
*/
PLAN_TABLE_OUTPUT
-----------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter(("OBJECT_ID"<12007 AND "OBJECT_ID">12001))
Column Projection Information (identified by operation id):
-----------------------------------------------------------
1 - "OBJECT_NAME"[VARCHAR2,128]
PLAN_TABLE_OUTPUT
-------------------------------------------------------------------------------- -----------------------
Note
-----
- rule based optimizer used (consider using cbo)
48 rows selected.
(2)
********************************************************************************************
After SQL Profile was created
********************************************************************************************
SQL> select * from table(dbms_xplan.display_cursor('0vk9qn0z3gkwr',null,'ADVANCED'));
PLAN_TABLE_OUTPUT
-----------------------------------------------------------------------
SQL_ID 0vk9qn0z3gkwr, child number 0
-------------------------------------
select /* pszope_txt */ object_name from x where object_id>12001 and
object_id<12007
Plan hash value: 1157146653
----------------------------------
| Id | Operation | Name |
----------------------------------
| 0 | SELECT STATEMENT | |
PLAN_TABLE_OUTPUT
-----------------------------------------------------------------------
|* 1 | TABLE ACCESS FULL| X |
----------------------------------
Query Block Name / Object Alias (identified by operation id):
-------------------------------------------------------------
1 - SEL$1 / X@SEL$1
Outline Data
-------------
PLAN_TABLE_OUTPUT
-----------------------------------------------------------------------
/*+
BEGIN_OUTLINE_DATA
IGNORE_OPTIM_EMBEDDED_HINTS
OPTIMIZER_FEATURES_ENABLE('10.2.0.3')
OPT_PARAM('optimizer_index_cost_adj' 1)
OPT_PARAM('optimizer_index_caching' 100)
RBO_OUTLINE
OUTLINE_LEAF(@"SEL$1")
FULL(@"SEL$1" "X"@"SEL$1")
END_OUTLINE_DATA
*/
PLAN_TABLE_OUTPUT
-----------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter(("OBJECT_ID"<12007 AND "OBJECT_ID">12001))
Column Projection Information (identified by operation id):
-----------------------------------------------------------
1 - "OBJECT_NAME"[VARCHAR2,128]
PLAN_TABLE_OUTPUT
-----------------------------------------------------------------------
Note
-----
- rule based optimizer used (consider using cbo)
SQL_ID 0vk9qn0z3gkwr, child number 1
-------------------------------------
select /* pszope_txt */ object_name from x where object_id>12001 and
object_id<12007
Plan hash value: 1157146653
PLAN_TABLE_OUTPUT
-----------------------------------------------------------------------
--------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | | | 968 (100)| |
|* 1 | TABLE ACCESS FULL| X | 11 | 869 | 968 (0)| 00:42:40 |
--------------------------------------------------------------------------
Query Block Name / Object Alias (identified by operation id):
-------------------------------------------------------------
1 - SEL$1 / X@SEL$1
PLAN_TABLE_OUTPUT
-----------------------------------------------------------------------
Outline Data
-------------
/*+
BEGIN_OUTLINE_DATA
IGNORE_OPTIM_EMBEDDED_HINTS
OPTIMIZER_FEATURES_ENABLE('10.2.0.3')
OPT_PARAM('optimizer_index_cost_adj' 1)
OPT_PARAM('optimizer_index_caching' 100)
OUTLINE_LEAF(@"SEL$1")
PLAN_TABLE_OUTPUT
-----------------------------------------------------------------------
FULL(@"SEL$1" "X"@"SEL$1")
END_OUTLINE_DATA
*/
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter(("OBJECT_ID">12001 AND "OBJECT_ID"<12007))
Column Projection Information (identified by operation id):
-----------------------------------------------------------
PLAN_TABLE_OUTPUT
-----------------------------------------------------------------------
1 - "OBJECT_NAME"[VARCHAR2,128]
Note
-----
- dynamic sampling used for this statement
- SQL profile "0vk9qn0z3gkwr" used for this statement
96 rows selected.
SQL>
Thanks and Regards
sysdba007
|
|
|
|