Re: LIKE optimization - Mailing list pgsql-novice

From Tom Lane
Subject Re: LIKE optimization
Date
Msg-id 12925.979667493@sss.pgh.pa.us
Whole thread Raw
In response to Re: LIKE optimization  (Nabil Sayegh <nsmail@sayegh.de>)
List pgsql-novice
Nabil Sayegh <nsmail@sayegh.de> writes:
> However, shouldn't "LIKE '%'" be ALWAYS ignored no matter how the
> database is structured?

It's a no-op at runtime, sure, but the planner does not know enough
about LIKE to realize that (at least not in the default 7.0.* setup;
you might want to look at contrib/likeplanning).

I'm guessing that the presence of the LIKE clauses is altering the
planner's row count estimates enough to change the plan it picks.
This is only a guess, however, since you still haven't shown us the
EXPLAIN results.  It's also very unclear whether or not you have done
a VACUUM ANALYZE --- without that, the planner is pretty much flying
blind.

            regards, tom lane

pgsql-novice by date:

Previous
From: Nabil Sayegh
Date:
Subject: Re: LIKE optimization
Next
From: "rob"
Date:
Subject: Re: LIKE optimization