X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id D292547622E for ; Mon, 12 May 2003 20:14:04 -0400 (EDT) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 1E6B7474E42 for ; Mon, 12 May 2003 20:14:00 -0400 (EDT) Received: from [216.135.165.74] (HELO temoku) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3029138; Mon, 12 May 2003 17:14:04 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: csajl , pgsql-performance@postgresql.org Subject: Re: [repost] partial index / funxtional idx or bad sql? Date: Mon, 12 May 2003 17:13:38 -0700 User-Agent: KMail/1.4.3 References: <20030513000746.70481.qmail@web40301.mail.yahoo.com> In-Reply-To: <20030513000746.70481.qmail@web40301.mail.yahoo.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200305121713.38449.josh@agliodbs.com> X-Spam-Status: No, hits=-22.7 required=5.0 tests=BAYES_01,IN_REP_TO,REFERENCES,USER_AGENT_KMAIL autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200305/138 X-Sequence-Number: 1917 Seth, > SELECT p.id, p.areacode, p.content=20 > FROM posts p > WHERE p.type_id =3D ? > AND p.areacode in ( > select areacode from areacodes > where site_id =3D ? > ) Unless you're using 7.4 from CVS, you want to get rid of that IN: SELECT p.id, p.areacode, p.content=20 FROM posts p WHERE p.type_id =3D ? AND EXISTS ( select areacode from areacodes where site_id =3D ? and p.areacode =3D areacodes.areacode ); See how that works, and if it's still slow, post the EXPLAIN ANALYZE. --=20 -Josh Berkus Aglio Database Solutions San Francisco