Subject Re: [firebird-support] 1=1 in where gets a bad performance
Author Gustavo Moda
Hi,

Try

select
sum(paritypos)
from ParityEx
where BeginParityDate between '2007/12/01' and '2008/11/30' and 1 =1

Check the column BeginParityDate, the column must have index.

Gustavo

2008/11/14 Fidel Viegas <fidel.viegas@...>

> On Fri, Nov 14, 2008 at 6:33 PM, kokok_kokok <kokok_kokok@...<kokok_kokok%40yahoo.es>>
> wrote:
> > I have a simple sql statement:
> >
> > select
> > sum(paritypos)
> > from ParityEx
> > where BeginParityDate between '2007/12/01' and '2008/11/30'
> >
> > It takes 400 mseg for 6000 records.
> >
> > The problem is the sql statement is created by a "wizard", for tech
> > questions, sometimes it adds 1=1, I thought that the SQL optimizer of
> > Firebird optimizes scenarios like this:
> >
> > select
> > sum(paritypos)
> > from ParityEx
> > where 1=1 and BeginParityDate between '2007/12/01' and '2008/11/30'
> >
> > but the above statement takes 5000 mseg, 12.5 times more!
> >
> > I am using FB 2.0, does somebody know if it will fixed in a future
> > version? or it is a usual behavior, is there a way to avoid this problem?
> >
>
> Hi kokok,
>
> There has been a discussion about this. Just do a search on previous
> posts. You should be able to find your answer there.
>
> Fidel.
>
>


[Non-text portions of this message have been removed]