Subject | Re: [firebird-support] Optimise OR in WHERE |
---|---|
Author | Kjell Rilbe |
Post date | 2013-10-11T11:51:48Z |
Den 2013-10-11 13:40 skrev Tim Ward såhär:
FOR SELECT <stuff> FROM <stuff>
WHERE <stuff> ...
AND ( (WIDGET starting with coalesce(:param, '') )
ORDER BY <stuff>
INTO <stuff>
DO
BEGIN
<stuff>
END
But I guess it works only if WIDGET is a char/varchar. Or might work on
other types as well if you add a computed index casting it to varchar...?
Does it work?
Regards,
Kjell
--
--------------------------------------
Kjell Rilbe
DataDIA AB
E-post: kjell@...
Telefon: 08-761 06 55
Mobil: 0733-44 24 64
>I did a little test, and I think this might work:
> Yes I know you can't optimise OR, so I'm looking for an alternative
> approach.
>
> I've come across a query in a stored procedure which goes like this:
>
> FOR SELECT <stuff> FROM <stuff>
> WHERE <stuff> ...
> AND ( (WIDGET= :param ) OR ( :param is null ) )
> ORDER BY <stuff>
> INTO <stuff>
> DO
> BEGIN
> <stuff>
> END
>
FOR SELECT <stuff> FROM <stuff>
WHERE <stuff> ...
AND ( (WIDGET starting with coalesce(:param, '') )
ORDER BY <stuff>
INTO <stuff>
DO
BEGIN
<stuff>
END
But I guess it works only if WIDGET is a char/varchar. Or might work on
other types as well if you add a computed index casting it to varchar...?
Does it work?
Regards,
Kjell
--
--------------------------------------
Kjell Rilbe
DataDIA AB
E-post: kjell@...
Telefon: 08-761 06 55
Mobil: 0733-44 24 64