From: Tom Lane <tgl@sss.pgh.pa.us>
To: Mark Lewis <mark.lewis@mir3.com>
Cc: Karthikeyan Mahadevan <karthikeyan.mahadevan@in.ibm.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: LIKE query verses =
Date: Wed, 29 Aug 2007 13:51:41 -0400
Message-ID: <7014.1188409901@sss.pgh.pa.us> (raw)
In-Reply-To: <1188407551.22730.113.camel@archimedes>
References: <OF2E7129A7.60680FDA-ON65257346.00445AD3-65257346.0044EA98@in.ibm.com>
<1188407551.22730.113.camel@archimedes>
Mark Lewis <mark.lewis@mir3.com> writes:
> What you probably want to do is tell PG that you're looking for a
> literal underscore and not for any matching character by escaping the
> underscore, that will allow it to do a much quicker index scan.
The other half of the problem is that the planner is drastically
misestimating the number of matching rows --- it thinks only one
when there are really about a thousand, and this leads it to use
a nestloop that will be very inefficient with so many rows.
Try increasing the statistics target for that column. Also, if
this is a pre-8.2 PG release, consider upgrading; I believe we
improved the LIKE estimator in 8.2.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: tgl@sss.pgh.pa.us, mark.lewis@mir3.com, karthikeyan.mahadevan@in.ibm.com
Subject: Re: LIKE query verses =
In-Reply-To: <7014.1188409901@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox