Subject | Re: [firebird-support] Opimize query with casted field |
---|---|
Author | Mitch Peek |
Post date | 2007-06-19T03:44:20Z |
Helen Borrie wrote:
Would this approach be better then an index on the timestamp and just
querying between Adate and Adate+1? if so, why?
The only problem I see might be the inclusion of the record which could
occur if an entry was exactly at midnight (00:00:00.0000)
BTW,
No need for the variable.
and an extra "end" before the else
:)
> In Firebird 2.0.x you can have an expression index - see release notes.Helen,
>
> In Fb 1.5.x and below you'd need to add a trigger-populated proxy
> column for DyStart and index that, e.g.
>
> Alter DY add DyStartdate DATE;
>
> create index ascDyStartdate on DY (DyStartdate);
>
> create trigger biu_DY for DY
> active before insert or update
> as
> declare vtimestamp timestamp;
> begin
> if (new.DyStart is not null) then
> new.DyStartdate = cast (new.DyStart as Date);
> end
> else
> if (updating and old.DyStart is not null) then
> new.DyStartdate = null;
> end
>
>
Would this approach be better then an index on the timestamp and just
querying between Adate and Adate+1? if so, why?
The only problem I see might be the inclusion of the record which could
occur if an entry was exactly at midnight (00:00:00.0000)
BTW,
No need for the variable.
and an extra "end" before the else
:)