You are on page 1of 6

2010

[BASIC SIEBEL QUERY TUNING]

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;

Mimic Siebel Query execution in SQL/PLUS prompt


To mimic the Siebel query execution make sure that you set above session parameters or follow below steps. Assume that we wanted to mimic below query.
SELECT NAME, loc, ou_num FROM siebel.s_org_ext WHERE ou_type_cd = :1 Bind variable 1: Customer

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.

Basic Query tuning steps


Steps 1. 2. 3. 4. Generate explain plan for Siebel query Analyze query & tentative solution Generate explain plan and check whether it uses new index or not as well as performance Actual test.

Generate explain plan for Siebel query


With exercise we will try to tune below query.
SELECT NAME, loc, ou_num FROM siebel.s_org_ext WHERE x_reference_type = 'Pune'

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

Analyze query & solution


One sql file is executed it will generate the LST file as above. Next steps it to analyze the LST file. Open LST file in any editor. In LST file at bottom you will see the explain plan similar to below.
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> 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

be good. New LST file attached for reference.


SELECT STATEMENT Cost =1 (Cost=1 Rows=10 Bytes=400)

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>

Actual Test of solution


To test out solution we will use below sql file and will execute same way as we executed for explain plan.

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

Original timings without index in place is as below.

GeneralQueryTuneT est.LST

Things to consider while tuning


y y Performance is also dependent on the how many physical gets are needed for SQL Query TKProof show internal details to DBA team

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

RE Siebel Query tuning and DBA help.m

You might also like