Professional Documents
Culture Documents
Contents
Background ............................................................................................................................................. 3 Mimic Siebel Query execution in SQL/PLUS prompt ................................................................................. 3 Basic Query tuning steps.......................................................................................................................... 4 Generate explain plan for Siebel query ................................................................................................ 4 Analyze query & solution ..................................................................................................................... 5 Testing solution ................................................................................................................................... 5 Actual Test of solution ......................................................................................................................... 6 Things to consider while tuning ............................................................................................................... 6 References............................................................................................................................................... 6
Background
Siebel Applications use a number of documented Oracle optimizer features that are designed and documented to bring back data faster. Application decides which optimizer parameter to pass to database connection based on type of component. For user session which is typically thru object manager, application used different optimizer setting compared to Workflow Monitor Agent which is background process. Based on my finding I can say that object manager uses FIRST_ROW as one of the session parameter where as background processes uses ALL_ROW as parameter. Below are the documented optimizer settings are used by object manager to connect to database to execute sql query.
alter session set optimizer_mode = FIRST_ROWS_10; alter session set "_hash_join_enabled" = FALSE; alter session set "_optimizer_sortmerge_join_enabled" = false; alter session set "_optimizer_join_sel_sanity_check" = true;
Adjusted query
alter session set optimizer_mode = 'FIRST_ROWS_10'; alter session set "_hash_join_enabled" = FALSE; alter session set "_optimizer_sortmerge_join_enabled" = false; alter session set "_optimizer_join_sel_sanity_check" = true; SELECT NAME, loc, ou_num FROM siebel.s_org_ext WHERE ou_type_cd = 'Customer'
Note: - Please make sure that yellow highlighted commands are executed one by one and one at a time.
To find out explain plan for query, use below sql file and replace appropriate sql statement, please make sure that you use bind variable instead of copying full sql statement.
GeneralQueryTune.s ql
Once you have sql file, use command prompt and execute query. As a result it will generate one LST file which will capture explain plan and output of query.
GeneralQueryTune.L ST
2.1 TABLE ACCESS FULL S_ORG_EXT -T1 TABLE (Cost=782 Rows=10 Bytes=400) <Filter: X_REFERENCE_TYPE=:B1> 2.1 TABLE ACCESS FULL S_ORG_EXT -T1 TABLE (Cost=782 Rows=10 Bytes=400) <Filter: X_REFERENCE_TYPE=:B1> SELECT STATEMENT Cost =782 (Cost=782 Rows=10 Bytes=400)
2.1 TABLE ACCESS FULL S_ORG_EXT -T1 TABLE (Cost=782 Rows=10 Bytes=400) <Filter: X_REFERENCE_TYPE=:B1> 2.1 TABLE ACCESS FULL S_ORG_EXT -T1 TABLE (Cost=782 Rows=10 Bytes=400) <Filter: X_REFERENCE_TYPE=:B1>
While analyzing the sql statement use general thumb rule as below. y y y Is there any full table scan? Is it using appropriate indexes? Do we have any filter?
While analyzing explain plan you will see that two rules are violated here. Full table scan as well filter is used while retrieving data. Simple solution here is to create index on x_reference_type.
Testing solution
Create index in database as below.
create index s_org_ext_temp on siebel.s_org_ext(x_reference_type)
Once index is created run same sql file again and check whether full table scan is used or not in explain plan. With index in plan check yellow marked changes, since it used appropriate index performance will
GeneralQueryTune.L ST
2.1 TABLE ACCESS BY INDEX ROWID S_ORG_EXT -T1 TABLE (Cost=1 Rows=10 Bytes=400) 3.1 INDEX RANGE SCAN S_ORG_EXT_TEMP INDEX (Cost=1 Rows=524 Bytes=) <Access: X_REFERENCE_TYPE=:B1> 3.1 INDEX RANGE SCAN S_ORG_EXT_TEMP INDEX (Cost=1 Rows=524 Bytes=) <Access: X_REFERENCE_TYPE=:B1> 2.1 TABLE ACCESS BY INDEX ROWID S_ORG_EXT -T1 TABLE (Cost=1 Rows=10 Bytes=400) 3.1 INDEX RANGE SCAN S_ORG_EXT_TEMP INDEX (Cost=1 Rows=524 Bytes=) <Access: X_REFERENCE_TYPE=:B1>
GeneralQueryTuneT est.sql
After completion check the timing in LST file at bottom which is 00:00:00.46 sec compared to original (00:00:15.98 sec)
GeneralQueryTuneT est.LST
GeneralQueryTuneT est.LST
References
y DocId 475230.1 : Generating Execution Plans for Oracle CBO on support web
y y y y y y
y
Refer attachment for details sent to DEV team as well as DBA Team DocId 481522.1: View is slow but SQL is fast DocId 742064.1 : Database Performance Considerations - Where indexes can improve performance and where not DocId 475683.1: How to generate tkprof/explain plan output?
DocID 477897.1: How Can Tracing Be Increased for the Siebel Object Manager? DocId 478028.1: Oracle CBO and Siebel Business Applications DocId 743170.1: WHITE PAPER FOR SIEBEL CRM WITH COST BASED OPTIMIZER ON 10g