Subject | 1=1 in where gets a bad performance |
---|---|
Author | kokok_kokok |
Post date | 2008-11-14T17:33:44Z |
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?
Thank you
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?
Thank you