Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Index and functions
Roger Wernersson wrote:
>
> I seem have a problem. I have a table with one number per hour
> and I want to get the sum of these per day, month, quarter and
> year. I created a view using "TRUNC (my_date, my_mask)" using
> another table with rows for each valid mask.
>
> The problem is that it is so slow. Is a selection based on this
> view using the index of the my_date-column even though I am using
> a function?
You should post the entire select statement so we can see how you are using the trunc call. For instance, if the where clause looks like this:
select ...
where the_date = trunc( my_date, my_mask );
then the call to trunc is made for every row examined. However, if you change it to
select ...
where the_date in (select trunc(my_date, my_mask) from dual);
then the call to trunc is made only once for the entire statement. Something like that could explain at least part of a slow response.
-- Tomm Carr ---- ---- Hunting for a job is like hunting for an elephant. If you're not *very* careful, you might find one!Received on Tue Aug 19 1997 - 00:00:00 CDT