Re: LIKE optimization

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Nabil Sayegh <nsmail(at)sayegh(dot)de>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: LIKE optimization
Date: 2001-01-16 17:51:33
Message-ID: 12925.979667493@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Nabil Sayegh <nsmail(at)sayegh(dot)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

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message rob 2001-01-17 01:42:20 Re: LIKE optimization
Previous Message Nabil Sayegh 2001-01-16 16:58:51 Re: LIKE optimization