Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id A67D79FB30E for ; Wed, 21 Feb 2007 01:34:39 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-new, port 10024) with ESMTP id 28543-10 for ; Wed, 21 Feb 2007 01:34:30 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from wx-out-0506.google.com (wx-out-0506.google.com [66.249.82.233]) by postgresql.org (Postfix) with ESMTP id 6ED379FB29D for ; Wed, 21 Feb 2007 01:34:36 -0400 (AST) Received: by wx-out-0506.google.com with SMTP id i28so2623808wxd for ; Tue, 20 Feb 2007 21:34:35 -0800 (PST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=FwWOb+R9Y8ip75NlM87dsYcT0dKJGDsN+EjHxlVZ++FqKE4QwwVS3P/pPN1u3neTfYGWQw5oBZ51xWncU8CT0djfeKRuxaKPIU8dX0E7u/1WuslCcXGfdF2X9NXs54lcxBW3wQdFG4l9KMcbzBfMQF6ZcoCOr9uZbmMJcX07RdQ= Received: by 10.90.90.3 with SMTP id n3mr9663719agb.1172036075809; Tue, 20 Feb 2007 21:34:35 -0800 (PST) Received: by 10.90.80.18 with HTTP; Tue, 20 Feb 2007 21:34:35 -0800 (PST) Message-ID: <58b7e6510702202134n45e1ef87tc8bc62b2586c43d7@mail.gmail.com> Date: Wed, 21 Feb 2007 14:34:35 +0900 From: "Marko Niinimaki" To: "Tom Lane" Subject: Re: slow subselects Cc: pgsql-performance@postgresql.org In-Reply-To: <22952.1171957386@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <58b7e6510702192302i6b526e56wee847a2122cec3aa@mail.gmail.com> <58b7e6510702192310v77517652q4ba8ecaf50ea161c@mail.gmail.com> <22952.1171957386@sss.pgh.pa.us> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200702/205 X-Sequence-Number: 23259 Many thanks! Ismo's reply solved the problem, and Tom's reply solved another one. Marko Ismo Tuononen wrote: > select studentid,max(score) from studentprofile group by studentid; On 20/02/07, Tom Lane wrote: > The optimal index for this would be on studentprofile(studentid,score).