Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> optimize this!
Hi,
I am trying to optimize the following sql statement (oracle 10g) but I can't
get anything better than an index range scan.
select distinct to_char(shopping_date,'MONTH/YYYY') d,
trunc(shopping_date,'MM') r
from bills
where owner_id = 25
order by 2 desc
(null) SELECT STATEMENT Optimizer=ALL_ROWS (Cost=3 Card=39 Bytes=390) (null)
1 0 _SORT (ORDER BY) (Cost=3 Card=39 Bytes=390) (null) 2 1 _SORT (UNIQUE) (Cost=2 Card=39 Bytes=390) (null) 3 2 _INDEX (RANGE SCAN) Of BILLS_IDX2 (INDEX) (Cost=1 Card=45Bytes=450) (null)
Table bills comes with the following indexes (table and indexes have been analyzed beforehand)
So, my question is, given the fact that the query is expected to select around 50 rows from a table containing some 10.000 rows, is the index range scan on index number 3 the best I can get?
Does it make any sense to define function indexes with functions like trunc that "flatten" values and therefore reduce selectivity?
Of course in my case it does not make sense to keep this function index as it is not going to be used ever.
Thanks,
Flavio
Received on Sun Oct 03 2004 - 05:46:55 CDT
![]() |
![]() |