Subject | Re: Superslowdown with an extra OR |
---|---|
Author | maximshiryaev |
Post date | 2008-04-23T12:50:36Z |
Hi.
From my experience any query with OR operator can be converted to
union if FB optimizer has some difficolties.
I mean:
SELECT *
FROM t
WHERE a = :a OR b = :b
can be substitutd by:
SELECT *
FROM t
WHERE a = :a
UNION ALL
SELECT *
FROM t
WHERE b = :b
In most cases it forces FB to use indicies on a and b columns if any.
The only problem is your FIRST 1 clause. Is it actually neccessary?
Maxim.
--- In firebird-support@yahoogroups.com, Tim Gahnström
<tim.gahnstrom@...> wrote:
explanation.
From my experience any query with OR operator can be converted to
union if FB optimizer has some difficolties.
I mean:
SELECT *
FROM t
WHERE a = :a OR b = :b
can be substitutd by:
SELECT *
FROM t
WHERE a = :a
UNION ALL
SELECT *
FROM t
WHERE b = :b
In most cases it forces FB to use indicies on a and b columns if any.
The only problem is your FIRST 1 clause. Is it actually neccessary?
Maxim.
--- In firebird-support@yahoogroups.com, Tim Gahnström
<tim.gahnstrom@...> wrote:
>have just run into a strange slowdown that probably has very simple
> Hi
>
> We are running an embedded Firebird on several hundred old PCs and
explanation.
>...