X-Original-To: pgsql-performance@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 82E86474E53 for ; Sun, 23 Feb 2003 15:53:25 -0500 (EST) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with SMTP id 23263-04 for ; Sun, 23 Feb 2003 15:53:14 -0500 (EST) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id A5737474E42 for ; Sun, 23 Feb 2003 15:53:14 -0500 (EST) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2853807; Sun, 23 Feb 2003 12:53:15 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Oleg Lebedev , "pgsql-performance@postgresql.org" Subject: Re: slow query Date: Sun, 23 Feb 2003 12:52:30 -0800 User-Agent: KMail/1.4.3 References: <993DBE5B4D02194382EC8DF8554A5273033583@postoffice.waterford.org> In-Reply-To: <993DBE5B4D02194382EC8DF8554A5273033583@postoffice.waterford.org> MIME-Version: 1.0 Message-Id: <200302231252.30681.josh@agliodbs.com> Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: by amavisd-new X-Archive-Number: 200302/166 X-Sequence-Number: 1222 Oleg, > I VACUUM ANALYZED both databases and made sure they have same indexes on > the tables. Have you VACUUM FULL the main database? And how about REINDEX?=20=20 > Here is the query: > SELECT * FROM media m, speccharacter c > WHERE m.mediatype IN (SELECT objectid FROM mediatype WHERE > medianame=3D'Audio') The above should use an EXISTS clause, not IN, unless you are absolutely su= re=20 that the subquery will never return more than 12 rows. --=20 Josh Berkus Aglio Database Solutions San Francisco