X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id D3D01D1B473 for ; Fri, 9 Jan 2004 08:55:38 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 72653-09 for ; Fri, 9 Jan 2004 04:54:50 -0400 (AST) Received: from anchor-post-32.mail.demon.net (anchor-post-32.mail.demon.net [194.217.242.90]) by svr1.postgresql.org (Postfix) with ESMTP id A1AEED1B477 for ; Fri, 9 Jan 2004 04:54:48 -0400 (AST) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-32.mail.demon.net with esmtp (Exim 3.35 #1) id 1AesPp-000MeW-0W; Fri, 09 Jan 2004 08:54:49 +0000 Received: by mainbox.archonet.com (Postfix, from userid 529) id ADF3517942; Fri, 9 Jan 2004 08:54:48 +0000 (GMT) Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id 12008178D5; Fri, 9 Jan 2004 08:54:47 +0000 (GMT) From: Richard Huxton To: Dennis =?iso-8859-1?q?Bj=F6rklund?= , Bradley Tate Subject: Re: Slow query problem Date: Fri, 9 Jan 2004 08:54:46 +0000 User-Agent: KMail/1.5 Cc: pgsql-performance@postgresql.org References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200401090854.46480.dev@archonet.com> X-Bogosity: No, tests=bogofilter, spamicity=0.000000, version=0.15.3 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200401/96 X-Sequence-Number: 5271 On Friday 09 January 2004 07:29, Dennis Bj=F6rklund wrote: > On Thu, 8 Jan 2004, Bradley Tate wrote: > > > > select invheadref, invprodref, sum(units) > > from invtran > > group by invheadref, invprodref > For the above query, shouldn't you have one index for both columns > (invheadref, invprodref). Then it should not need to sort at all to do the > grouping and it should all be fast. Not sure if that would make a difference here, since the whole table is bei= ng=20 read.=20 --=20 Richard Huxton Archonet Ltd