Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Query CBO Cost - Hints
Well I did run some tests ... and lol I was able to finally recreate the case.
and from what I see, in the simple case above, the
CBO refused to look at the index plans in the non-hinted deletes (Even
when I deleted
29988 out of 30000 rows .. and rebuilt the bitmap index).
However in the hinted query, cost did appear as 1.
So basically the CBO never even considered the index access in my test
case.
I could however, not reproduce the original posters case (who later
admitted that
the query he posted was in reality different).
Here were the results (snipped) which somehow do prove my statement
wrong that
hinting with an index can indeed result in lower cost. However, not
sure whether I should have expected CBO to consider the index access in
this special case when the consistent gets would have reduced. :
Non-Hinted:
DELETE STATEMENT 0 DELETE DELTAB 1 TABLE ACCESS DELTAB FULL 2 1
Hinted:
Index: DELTAB_BMIDX
TABLE: DELTAB
RSC_CPU: 0 RSC_IO: 2
IX_SEL: 1.0000e+00 TB_SEL: 1.0000e+00
BEST_CST: 1.00 PATH: 4 Degree: 1
DELETE STATEMENT 0 DELETE DELTAB 1 INDEX DELTAB_BMIDX FULL SCAN 2 1
......
And here are the results of the autotrace:
ORA92> delete from deltab;
12 rows deleted.
Elapsed: 00:00:01.34
Execution Plan
0 DELETE STATEMENT Optimizer=CHOOSE (Cost=31 Card=12 Bytes=96)
1 0 DELETE OF 'DELTAB'
2 1 TABLE ACCESS (FULL) OF 'DELTAB' (Cost=31 Card=12
Bytes=96)
Statistics
0 recursive calls 64 db block gets 196 consistent gets 0 physical reads 8284 redo size 784 bytes sent via SQL*Net to client 784 bytes received via SQL*Net from client 4 SQL*Net roundtrips to/from client 1 sorts (memory) 0 sorts (disk) 12 rows processed
ORA92> rollback;
Rollback complete.
Elapsed: 00:00:00.03
ORA92> delete /*+ index(deltab deltab_bmidx) */ from deltab;
12 rows deleted.
Elapsed: 00:00:01.33
Execution Plan
0 DELETE STATEMENT Optimizer=CHOOSE (Cost=2 Card=12 Bytes=96)
1 0 DELETE OF 'DELTAB'
2 1 INDEX (FULL SCAN) OF 'DELTAB_BMIDX' (NON-UNIQUE) (Cost=1
Card=12 Bytes=96)
Statistics
0 recursive calls 19 db block gets 1 consistent gets 0 physical reads 4288 redo size 784 bytes sent via SQL*Net to client 818 bytes received via SQL*Net from client 4 SQL*Net roundtrips to/from client 3 sorts (memory) 0 sorts (disk) 12 rows processed
Thanks,
Anurag Received on Fri Apr 08 2005 - 17:05:30 CDT