Subject | Opimize query with casted field |
---|---|
Author | Josef Gschwendtner |
Post date | 2007-06-18T14:55:27Z |
Hi,
we have a big table (several million records) and like to select the
records regarding one day:
Within the table there is a field (DyStart) which is a Timestamp.
A convienient way to select would be:
select * from DY where cast(DyStart as Date) = :DayOfInterest (e.g.
'31.6.2007')
Sadly this select cann't use the index on field DyStart.
Therefore the select has to be something like:
... where DyStart >= :DayOfInterest and DyStart < :DayOfInterest + 1
Can you think about something more convenient?
Is there a way to optimize the first select (with cast)?
Thank you for your help,
Josef Gschwendtner
we have a big table (several million records) and like to select the
records regarding one day:
Within the table there is a field (DyStart) which is a Timestamp.
A convienient way to select would be:
select * from DY where cast(DyStart as Date) = :DayOfInterest (e.g.
'31.6.2007')
Sadly this select cann't use the index on field DyStart.
Therefore the select has to be something like:
... where DyStart >= :DayOfInterest and DyStart < :DayOfInterest + 1
Can you think about something more convenient?
Is there a way to optimize the first select (with cast)?
Thank you for your help,
Josef Gschwendtner