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 1B9043A443F for ; Fri, 7 Jan 2005 20:12:05 +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 04097-09 for ; Fri, 7 Jan 2005 20:11:43 +0000 (GMT) Received: from davinci.ethosmedia.com (server226.ethosmedia.com [209.128.84.226]) by svr1.postgresql.org (Postfix) with ESMTP id 53B933A4AA9 for ; Fri, 7 Jan 2005 20:11:47 +0000 (GMT) Received: from [64.81.245.111] (account josh@agliodbs.com HELO temoku.sf.agliodbs.com) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 6878925; Fri, 07 Jan 2005 12:13:25 -0800 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: David Jaquay Subject: Re: Query across a date range Date: Fri, 7 Jan 2005 12:15:27 -0800 User-Agent: KMail/1.7.1 Cc: pgsql-performance@postgresql.org References: <20050107182106.6CBEC5AF685@svr4.postgresql.org> <200501071135.11229.josh@agliodbs.com> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200501071215.27782.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.016 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200501/82 X-Sequence-Number: 9772 Dave, Ah .... > -> Seq Scan on sales_tickets s (cost=0.00..89543.50 > rows=626783 width=12) (actual time=38.017..19387.447 rows=713846 > loops=1) This is just more than 1/2 the time of your query. The issue is that you're pulling 713,000 rows (PG estimates 626,000 which is in the right ballpark) and PG thinks that this is enough rows where a seq scan is faster. It could be right. You can test that, force an indexscan by doing: SET enable_seqscan = FALSE; Also, please remember to run each query 3 times and report the time of the *last* run to us. We don't want differences in caching to throw off your evaulation. -- --Josh Josh Berkus Aglio Database Solutions San Francisco