From: Josh Berkus <josh@agliodbs.com>
To: csajl <csajl@yahoo.com>
To: pgsql-performance@postgresql.org
Subject: Re: [repost] partial index / funxtional idx or bad sql?
Date: Mon, 12 May 2003 17:13:38 -0700
Message-ID: <200305121713.38449.josh@agliodbs.com> (raw)
In-Reply-To: <20030513000746.70481.qmail@web40301.mail.yahoo.com>
References: <20030513000746.70481.qmail@web40301.mail.yahoo.com>
Seth,
> SELECT p.id, p.areacode, p.content
> FROM posts p
> WHERE p.type_id = ?
> AND p.areacode in (
> select areacode from areacodes
> where site_id = ?
> )
Unless you're using 7.4 from CVS, you want to get rid of that IN:
SELECT p.id, p.areacode, p.content
FROM posts p
WHERE p.type_id = ?
AND EXISTS (
select areacode from areacodes
where site_id = ?
and p.areacode = areacodes.areacode
);
See how that works, and if it's still slow, post the EXPLAIN ANALYZE.
--
-Josh Berkus
Aglio Database Solutions
San Francisco
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-performance@postgresql.org
Cc: josh@agliodbs.com, csajl@yahoo.com
Subject: Re: [repost] partial index / funxtional idx or bad sql?
In-Reply-To: <200305121713.38449.josh@agliodbs.com>
References: <20030513000746.70481.qmail@web40301.mail.yahoo.com> <200305121713.38449.josh@agliodbs.com>
* 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