X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 3A9C211F662E for ; Thu, 30 Mar 2006 08:43:00 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 43155-02 for ; Thu, 30 Mar 2006 08:42:59 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from vms044pub.verizon.net (vms044pub.verizon.net [206.46.252.44]) by postgresql.org (Postfix) with ESMTP id 38E4711F662B for ; Thu, 30 Mar 2006 08:42:58 -0400 (AST) Received: from osgiliath.mathom.us ([151.200.254.241]) by vms044.mailsrvcs.net (Sun Java System Messaging Server 6.2-4.02 (built Sep 9 2005)) with ESMTPA id <0IWX00BNPXZLTU03@vms044.mailsrvcs.net> for pgsql-performance@postgresql.org; Thu, 30 Mar 2006 06:42:58 -0600 (CST) Received: from localhost (localhost [127.0.0.1]) by osgiliath.mathom.us (Postfix) with ESMTP id D75A16E81B; Thu, 30 Mar 2006 07:42:55 -0500 (EST) Received: from osgiliath.mathom.us ([127.0.0.1]) by localhost (osgiliath.home.mathom.us [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 00546-05; Thu, 30 Mar 2006 07:42:55 -0500 (EST) Received: by osgiliath.mathom.us (Postfix, from userid 1000) id AA85A6E84A; Thu, 30 Mar 2006 07:42:54 -0500 (EST) Date: Thu, 30 Mar 2006 07:42:53 -0500 From: Michael Stone Subject: Re: Index scan startup time In-reply-to: <20060330123134.GA13408@uio.no> To: pgsql-performance@postgresql.org Cc: Peter Eisentraut Mail-followup-to: pgsql-performance@postgresql.org, Peter Eisentraut Message-id: <20060330124251.GK6811@mathom.us> MIME-version: 1.0 Content-type: text/plain; charset=utf-8; format=flowed Content-transfer-encoding: 8BIT Content-disposition: inline X-Pgp-Fingerprint: 53 FF 38 00 E7 DD 0A 9C 84 52 84 C5 EE DF 7C 88 X-Virus-Scanned: Debian amavisd-new at mathom.us References: <200603301359.11038.peter_e@gmx.net> <20060330120206.GA13075@uio.no> <200603301423.54510.peter_e@gmx.net> <20060330123134.GA13408@uio.no> User-Agent: Mutt/1.5.11+cvs20060126 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=1.17 required=5 tests=[AWL=-0.066, RCVD_IN_SORBS_WEB=1.236] X-Spam-Score: 1.17 X-Spam-Level: * X-Archive-Number: 200603/614 X-Sequence-Number: 18051 On Thu, Mar 30, 2006 at 02:31:34PM +0200, Steinar H. Gunderson wrote: >Well, it's logical enough; it scans along activity_id until it finds one with >state=10000 or state=10001. You obviously have a _lot_ of records with low >activity_id and state none of these two, so Postgres needs to scan all those >records before it founds 100 it can output. This is the “startup cost” you're >seeing. Yes. And the estimates are bad enough (orders of magnitude) that I can't help but wonder whether pg could come up with a better plan with better statistics: >>>> -> Index Scan using activity_pk on activity (cost=0.00..40717259.91 rows=6538650 width=8) (actual time=207356.050..207356.722 rows=100 loops=1) Filter: ((state = 10000) OR (state = 10001)) Mike Stone