Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Performance of trunc(date_column) and indexes...

Re: Performance of trunc(date_column) and indexes...

From: Mike Burden <michael.burden_at_capgemini.co.uk>
Date: Thu, 21 Jan 1999 15:41:51 +0000
Message-ID: <36A74ABF.A03958B3@capgemini.co.uk>


As the TRUNC function is not on the indexable column the optimizer should be able to use the index. You may need to collect stats on the column.

What wouldn't work would be

TRUNC(datastamp) = TRUNC(sysdate)

Jonathan Waland wrote:

> I have a procedure that takes datestamped data, and summaries it based
> on hour.
>
> There is an index on the datestamp column, but of course the use of a
> function on the column stops the use of the index:
>
> insert into summary
> select trunc(datestamp,'HH24') newdatestamp,
> sum(somecounterA),
> sum(somecounterB),
> max(somecounterC)
> where datestamp >= trunc(sysdate -1) and datestamp < trunc(sysdate)
> group by trunc(datestamp,'HH24');
>
> [about 22Million records in the table, going back 58 days, average
> 13,000 records per hour]
>
> Anyone any suggestions on how to speed it up. Currently using Oracle
> 7.3.3.5, and the cost based optimiser.
>
> Jon Waland
> Vodafone Ltd.
Received on Thu Jan 21 1999 - 09:41:51 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US