Subject Re: [firebird-support] Query optimatization
Author DB² Soluções - Listas
Why you dont sele only this:

select distinct extract(day from evttime) c
from events where extract(year from evttime)=2004 and
extract(month from evttime)=09 and empid=41

Because you know a year and mounth. Correct?


Gustavo Büchle
DB² Soluções
(51) 464-1417
(51) 9951-8712
Brasil!


----- Original Message -----
From: "Szalai Kálmán" <szalaik@...>
To: <firebird-support@yahoogroups.com>
Sent: Friday, November 12, 2004 10:03 AM
Subject: [firebird-support] Query optimatization


>
> Hello!
>
> Are there any way to optimize this query?
>
> "select distinct extract(year from evttime) a,extract(month from
> evttime) b,extract(day from evttime) c from events where extract(year
> from evttime)=2004 and
> extract(month from evttime)=09 and empid=41"
>
> It makes lot of Non indexed reads on EVENTS table.
>
> Currently I have got 2 Index and one primary key on this table:
>
> DDLs:
>
> ALTER TABLE EVENTS ADD PRIMARY KEY (EVTID);
>
> CREATE INDEX IDX_EVENTS_EVTTIME ON EVENTS (EVTTIME);
> CREATE DESCENDING INDEX NEWEVTID ON EVENTS (EVTID);
>
> So how can I speed up? How can I turn non indexed reads to indexed reads?
>
> Thanks,
> KAMI
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
>