Subject | Re: [firebird-support] is there a way around the IN clause? |
---|---|
Author | Gary Benade |
Post date | 2004-09-09T13:31:55Z |
if I change this
select c.name, c.surname, c.telephone, c.lastorderdate
from customers c
where not exists (select 1 from orders
where customerlink = c.link
and recdate > '01-jan-2004'
and recdate < '01-mar-2004'
and branchcode = 'SAN')
and c.branchcode = 'SAN'
order by lastorderdate desc,1,2
PLAN SORT ((C INDEX (IDX_CUSTOMERS_BRANCHCODE)))
PLAN (ORDERS INDEX (ORDERS_CUSTOMERLINK,ORDERS_RECDATE))
to this
select c.name, c.surname, c.telephone, c.lastorderdate
from customers c
where not exists (select 1 from orders
where customerlink = c.link
and recdate > '01-jan-2004'
and recdate < '01-mar-2004')
and c.branchcode = 'SAN'
order by lastorderdate desc,1,2
PLAN SORT ((C INDEX (IDX_CUSTOMERS_BRANCHCODE)))
PLAN (ORDERS INDEX (ORDERS_CUSTOMERLINK))
the query runs in, wait for it, 3 seconds initially and 0,2 seconds for
subsequent queries :) - much more like the firebird I know.
I just dont understand why the index on recdate is not being used?
Thanks again Martjin, Luc, Daniel and Helen for your input
Regards
Gary
select c.name, c.surname, c.telephone, c.lastorderdate
from customers c
where not exists (select 1 from orders
where customerlink = c.link
and recdate > '01-jan-2004'
and recdate < '01-mar-2004'
and branchcode = 'SAN')
and c.branchcode = 'SAN'
order by lastorderdate desc,1,2
PLAN SORT ((C INDEX (IDX_CUSTOMERS_BRANCHCODE)))
PLAN (ORDERS INDEX (ORDERS_CUSTOMERLINK,ORDERS_RECDATE))
to this
select c.name, c.surname, c.telephone, c.lastorderdate
from customers c
where not exists (select 1 from orders
where customerlink = c.link
and recdate > '01-jan-2004'
and recdate < '01-mar-2004')
and c.branchcode = 'SAN'
order by lastorderdate desc,1,2
PLAN SORT ((C INDEX (IDX_CUSTOMERS_BRANCHCODE)))
PLAN (ORDERS INDEX (ORDERS_CUSTOMERLINK))
the query runs in, wait for it, 3 seconds initially and 0,2 seconds for
subsequent queries :) - much more like the firebird I know.
I just dont understand why the index on recdate is not being used?
Thanks again Martjin, Luc, Daniel and Helen for your input
Regards
Gary