Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: optimize this!
On Wed, 06 Oct 2004 17:51:15 GMT, FC wrote:
> "Brian Dick" <bdick_at_cox.net> wrote in message > news:1qwnhcmginupg.voodgd7dxvvb$.dlg_at_40tude.net...
> 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=45
>>>> Bytes=450) (null)
>>>>
> been>>>> 2) a btree index on columns owner_id and id (used by other queries)
>>>> analyzed beforehand)
>>>>
>>>> 1) a primary key index on column id which is not part of this query.
> actually>>>> 4) a function index on owner_id, to_char(shopping_date,'MONTH/YYYY'),
>>>> picked by the optimizer)
> presume.>>>> So, my question is, given the fact that the query is expected to select
>>>>
> range>>>>
>>>> scan on index number 3 the best I can get?
> trunc>>>>
>>>> that "flatten" values and therefore reduce selectivity?
> as>>> Personally I'd expect that a full table scan wouldn't hurt with such a
>>>> it is not going to be used ever.
>>>>
>>>> Thanks,
>>>> Flavio
>>>
>>> You want better than a cost of 3 ... why? Don't you have a job to do?
>>>
> a
> > > Roughly 2000 ~ 3000 rows. > > Bye, > Flavio
From your plan above it looks like you are sorting about 10 bytes per row. With 3000 rows this would be about 30K. The sorts should not be an issue either. Received on Fri Oct 08 2004 - 10:19:36 CDT