Robert Roggenbuck wrote:
> Hi Mark,
>
> not all can be done by LIKE and must be formulated in a long-ish
> OR-chain. But some cases can be treated be the LIKE-like SIMILAR. With
> it it should be possible to say
>
> SELECT pets, colors FROM Table WHERE (
>     (lower(pets) SIMILAR TO lower('%?%|%?%') )
>      OR
>     (lower(colors) SIMILAR TO lower('%?%|%?%') )
>     )
>   @bind = ('cat','brown','cat','brown');
>
> instead of
>
> SELECT pets, colors FROM Table WHERE (
>     (lower(pets) ~ lower(?)
>      OR lower(colors) ~ lower(?)
>     )
>      OR
>     (lower(pets) ~ lower(?)
>      OR lower(colors) ~ lower(?)
>     ))
>   @bind = ('cat','cat','brown','brown');
>
> I did not tested the syntax, but regarding the SQL-rules it should be
> possible. This will shorten the statements and may be improve the
> performance.

Robert,

This optimization looks reasonable. Would you be interested in
submitting a patch? It would also be interesting to see benchmarks to
see if there's really much difference.

    Mark

--
http://mark.stosberg.com/

Reply via email to