X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 527B6564B8 for ; Thu, 3 Mar 2005 05:31:58 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 31100-02 for ; Thu, 3 Mar 2005 05:31:54 +0000 (GMT) Received: from davinci.ethosmedia.com (server227.ethosmedia.com [209.128.84.227]) by svr1.postgresql.org (Postfix) with ESMTP id 18BD256491 for ; Thu, 3 Mar 2005 05:31:51 +0000 (GMT) X-EthosMedia-Virus-Scanned: no infections found Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 7086502; Wed, 02 Mar 2005 21:33:38 -0800 From: Josh Berkus Organization: Aglio Database Solutions To: "Shawn Chisholm" Subject: Re: Performance tradeoff Date: Wed, 2 Mar 2005 21:31:01 -0800 User-Agent: KMail/1.6.2 Cc: References: <71837C040963F748B9B94E123A28967805710B@mailserver.sandvine.com> In-Reply-To: <71837C040963F748B9B94E123A28967805710B@mailserver.sandvine.com> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200503022131.01658.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.011 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200503/47 X-Sequence-Number: 10752 Shawn, > I can also change the schema to a certain extent, so would it be worthwhile > to put indices on the queried tables (or refactor them) hoping the distinct > does an index scan instead of sort... would the query planner take > advantage of that? Use the GROUP BY, with an index on the grouped columns and lots of work_mem (sort_mem in 7.4). This will give the planner the option of a hashaggregate which could be significantly faster than the other methods. -- Josh Berkus Aglio Database Solutions San Francisco