X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 68C9CD1B9F4 for ; Fri, 29 Aug 2003 03:00:55 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 71196-06 for ; Fri, 29 Aug 2003 00:00:44 -0300 (ADT) Received: from mail.speakeasy.net (mail15.speakeasy.net [216.254.0.215]) by svr1.postgresql.org (Postfix) with ESMTP id 89CE3D1B9B2 for ; Fri, 29 Aug 2003 00:00:37 -0300 (ADT) Received: (qmail 9218 invoked by uid 64014); 29 Aug 2003 03:00:36 -0000 Received: from kgeis@speakeasy.org by mail15.speakeasy.net with AmikaGuardian-Server-2.0.0 (Processed in 0.290994 secs); 29 Aug 2003 03:00:36 -0000 X-AmikaGuardian-Id: mail15.speakeasy.net10621260362369157 X-AmikaGuardian-Category: AN:Urgency : 0.03 X-AmikaGuardian-Category: AN:Vectored : 1.7 X-AmikaGuardian-Category: AN:Spam Language : 0.03 X-AmikaGuardian-Category: AN:Forwarded Mail : 1.7 X-AmikaGuardian-Category: AN:Override : 1.7 X-AmikaGuardian-Category: AN:Junk Mail : 0.03 X-AmikaGuardian-Category: AN:Exception : 1.7 X-AmikaGuardian-Category: AN:Spam : 0.03 X-AmikaGuardian-Action: Do Nothing() Received: from unknown (HELO speakeasy.org) (kgeis@[67.113.18.226]) (envelope-sender ) by mail15.speakeasy.net (qmail-ldap-1.03) with AES256-SHA encrypted SMTP for ; 29 Aug 2003 03:00:35 -0000 Message-ID: <3F4EC1D0.5010503@speakeasy.org> Date: Thu, 28 Aug 2003 20:00:32 -0700 From: Ken Geis User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Bruno Wolff III Cc: pgsql-performance@postgresql.org Subject: Re: bad estimates / non-scanning aggregates References: <3F4E99F7.7080604@speakeasy.org> <20030829025109.GD4373@wolff.to> <3F4EBF7E.8020602@speakeasy.org> <20030829030156.GF4373@wolff.to> In-Reply-To: <20030829030156.GF4373@wolff.to> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200308/461 X-Sequence-Number: 3277 Bruno Wolff III wrote: >>Not according to the optimizer! Plus, this is not guaranteed to return >>the correct results. > > For it to be fast you need an index on (stock_id, price_date) so that > you can use an index scan. I already said that such an index existed. In fact, it is the primary key of the table. And yes, I *am* analyzed! > The answers are guarenteed to be correct. See: > http://developer.postgresql.org/docs/postgres/sql-select.html#SQL-DISTINCT That's good to know. Thanks! Ken