Subject | Re: Query optimatization |
---|---|
Author | Svein Erling Tysvær |
Post date | 2004-11-12T12:50:56Z |
Hi, I guess you could create an index on (empid, evttime) in that
order and change the where part of your query to
where evttime between '01.09.2004' and '30.09.2004' and empid = 41
Extract in the where part of a query can never use an index.
HTH,
Set
order and change the where part of your query to
where evttime between '01.09.2004' and '30.09.2004' and empid = 41
Extract in the where part of a query can never use an index.
HTH,
Set
--- In firebird-support@yahoogroups.com, Szalai Kálmán wrote:
> 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