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 3E139D1B8C6 for ; Fri, 29 Aug 2003 04:19:07 +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 76610-10 for ; Fri, 29 Aug 2003 01:18:56 -0300 (ADT) Received: from wolff.to (wolff.to [66.93.249.74]) by svr1.postgresql.org (Postfix) with SMTP id 8FEEDD1B8AB for ; Fri, 29 Aug 2003 01:18:55 -0300 (ADT) Received: (qmail 5978 invoked by uid 500); 29 Aug 2003 04:24:53 -0000 Date: Thu, 28 Aug 2003 23:24:53 -0500 From: Bruno Wolff III To: kgeis@alum.calberkeley.org Cc: pgsql-performance@postgresql.org Subject: Re: bad estimates Message-ID: <20030829042453.GA5931@wolff.to> Mail-Followup-To: kgeis@alum.calberkeley.org, pgsql-performance@postgresql.org References: <3F4E99F7.7080604@speakeasy.org> <20030829025109.GD4373@wolff.to> <3F4EBF7E.8020602@speakeasy.org> <20030829030156.GF4373@wolff.to> <3F4EC1D0.5010503@speakeasy.org> <20030829033818.GA5577@wolff.to> <3F4ECC78.7090502@speakeasy.org> <20030829040519.GA5746@wolff.to> <3F4ED1DC.50808@speakeasy.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3F4ED1DC.50808@speakeasy.org> User-Agent: Mutt/1.5.4i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200308/467 X-Sequence-Number: 3283 On Thu, Aug 28, 2003 at 21:09:00 -0700, Ken Geis wrote: > Bruno Wolff III wrote: > > I am positive! I can send a log if you want, but I won't post it to the > list. Can you do a \d on the real table or is that too sensitive? It still doesn't make sense that you have a primary key that is a stock and its price. What happens when the stock has the same price on two different dates? And I doubt that you are looking for the minimum and maximum dates for which you have price data. So it is hard to believe that the index for your primary key is the one you need for your query. > The arity on the data is roughly 1500 price_dates per stock_id. Two index scans (one for min values and another for max values) should be better than one sequential scan under those conditions. I am calling it quits for tonight, but will check back tomorrow to see how things turned out.