Re: [repost] partial index / funxtional idx or bad sql?

From: Josh Berkus <josh(at)agliodbs(dot)com>
To: csajl <csajl(at)yahoo(dot)com>, pgsql-performance(at)postgresql(dot)org
Subject: Re: [repost] partial index / funxtional idx or bad sql?
Date: 2003-05-13 00:13:38
Message-ID: 200305121713.38449.josh@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

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

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message csajl 2003-05-13 00:47:10 Re: [repost] partial index / funxtional idx or bad sql?
Previous Message csajl 2003-05-13 00:07:46 [repost] partial index / funxtional idx or bad sql?