On 3/14/07, Wiebe Cazemier <halfgaar@gmx.net> wrote:
> I discovered that removing the subselect (the entire second condition of
> the join actually) is not the only thing that speeds it up. If I remove
> the LIKE check on account.description, it's also a lot faster (152 ms
> as opposed to 2915 ms), although not as fast as without the subselect.
> I don't understand why that makes such a big difference. There is an
> index on upper() on the field.
From http://www.postgresql.org/docs/8.2/static/indexes-types.html :
"The optimizer can also use a B-tree index for queries involving the
pattern matching operators LIKE and ~ if the pattern is a constant and
is anchored to the beginning of the string — for example, col LIKE
'foo%' or col ~ '^foo', but not col LIKE '%bar'."