What influences cost? [message #65754] |
Tue, 21 December 2004 11:08  |
Shane Kaszyca
Messages: 16 Registered: May 2003
|
Junior Member |
|
|
I have a table - "folder". Two columns of importance are folder_id and folder_path. I have an index on the column "folder_path". The cost of one of the queries is significantly higher than the other, and I have no clue why. Can anyone give me an idea of how I can determine why the cost is higher? I can provide more information if you require.
Query 1:
select folder_id from folder
where folder_path='/TKB/Compliance/International U.S.'
Cost 1: 82
Query 2:
select folder_id from folder
where folder_path='/TKB/Compliance/Federal U.S.'
Cost 2: 2
The table has approximately 217000 entries in it. About 183000 of the rows have null for the folder_path and the other 34000 have a unique value. Your help is much appreciated.
|
|
|
|
|
|
|
Re: What influences cost? [message #65762 is a reply to message #65761] |
Wed, 22 December 2004 03:59   |
 |
Mahesh Rajendran
Messages: 10708 Registered: March 2002 Location: oracleDocoVille
|
Senior Member Account Moderator |
|
|
>>. It seems to me that the cost of these two queries I have posted should be close, if not identical, as the column used in the where clause is in an indexed column.
NO.
Not a must.
All becuase a column is indexed it doesnt mean that the cost should be high or low .
It actually depends on the number of rows scanned.
If the index is used in your query, it may be a litter faster.
There are many reason why the query may not use an index.
and sometimes ( if there is too many rows to be returned)
CBO will not use an index , becuase it is much efficient to have full table scan.
So first update the statistics of your table.
then look into execution plan.
Please have a look in this thread
http://www.orafaq.com/forum/t/23478/0/
and the followup thread by Frank
http://www.orafaq.com/forum/t/23478/0/
[Updated on: Fri, 18 February 2005 23:32] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
|
|
|