Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: why does a higher cost run faster?
Haroon,
Apart from the excellent optimizer related information given by Wolfgang '10053' Breitling, you should be aware that since this is an Apps Database, you will need to have performed some setup prior to executing your query. Since you are querying MTL_SYSTEM_ITEMS_B for a particular Organization, you need to have already set your ORG_ID that will be used by the predicate which uses FND_PROFILE. I ask because your query returned 0 rows....
If not, then you will need to use the 'execute apps.Fnd_Client_Info.set_org_context('<your org>')' call to set this. Aaaand, as a result of this, your cost may vary and the whole question is moot since the query did not achieve what you wanted it to.
Also, keep in mind that Oracle Apps uses a different (and sensible IMHO) scheme for determining which columns need Histograms (ORG_ID is usually a favorite one, and it seems that MTL_SYSTEM_ITEMS_B does have histograms defined for this column). Have a look at my paper "Judicious Use of Histograms for Oracle Applications Tuning" available from http://oubpb.com/requestwp.html where I deal with how this is done.
Hth,
John Kanagaraj <><
DB Soft Inc
Phone: 408-970-7002 (W)
Co-Author: Oracle Database 10g Insider Solutions http://www.samspublishing.com/title/0672327910
-----Original Message-----
From: oracle-l-bounce_at_freelists.org
[mailto:oracle-l-bounce_at_freelists.org] On Behalf Of Haroon A. Qureshi
Sent: Thursday, December 15, 2005 12:49 PM
To: oracle-l_at_freelists.org
Subject: why does a higher cost run faster?
i have the following query in oracle apps:
1 select inventory_item_id code, description meaning, description
2 from mtl_system_items_b
3 where organization_id = fnd_profile.value('ORG_ID')
4 and 63 = 63
5* order by 2
no rows selected
Elapsed: 00:03:04.89
Execution Plan
0
SELECT STATEMENT Optimizer=CHOOSE (Cost=7794 Card=118186
Bytes=3663766)
1 0
2 1
the cost is 7073. when i force it use a concatenated index on organization_id and description, the cost jumps to 110381 but runs instantaneously.
SQL> start q1
no rows selected
Elapsed: 00:00:00.04
Execution Plan
0
SELECT STATEMENT Optimizer=CHOOSE (Cost=110381 Card=118186
Bytes=3663766)
1 0
2 1
3 2 INDEX (RANGE SCAN) OF 'MTL_SYSTEM_ITEMS_B_N2'
any ideas on why that is? am i not gathering my stats correctly?
thanks,
haroon
-- http://www.freelists.org/webpage/oracle-l -- http://www.freelists.org/webpage/oracle-lReceived on Thu Dec 15 2005 - 16:12:26 CST
![]() |
![]() |