From: Tom Lane <tgl@sss.pgh.pa.us>
To: The Hermit Hacker <scrappy@hub.org>
Cc: pgsql-sql@postgresql.org
Subject: Re: [7.0.3] optimizing a LIKE query ...
Date: Wed, 04 Apr 2001 19:06:03 -0400
Message-ID: <12999.986425563@sss.pgh.pa.us> (raw)
In-Reply-To: <Pine.BSF.4.33.0104041156540.81918-100000@mobile.hub.org>
References: <Pine.BSF.4.33.0104041156540.81918-100000@mobile.hub.org>
The Hermit Hacker <scrappy@hub.org> writes:
> I'm figuring that if I can somehow get the query (using subselects,
> maybe?), to have the LIKE part of the query work only on the 6k records
> returned by the "=" part of it, the overall results should be faster ...
In 7.0.* I think the only way to do that is to select into a temp table
and then apply the LIKE while selecting from the temp table.
In 7.1 you could possibly force the order by using a subselect (although
offhand I think the planner might be smart enough to see through that,
and do what it thinks is right anyway). The real problem is the planner
thinks that LIKE '%http://www.postgresql.org/%%'; is really selective; it
has no idea that most of your table mentions pgsql.org URLs :-(. We
need better statistics to fix this properly. (On my list for 7.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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, scrappy@hub.org
Subject: Re: [7.0.3] optimizing a LIKE query ...
In-Reply-To: <12999.986425563@sss.pgh.pa.us>
References: <Pine.BSF.4.33.0104041156540.81918-100000@mobile.hub.org> <12999.986425563@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