Received: from localhost (unknown [200.46.204.184]) by developer.postgresql.org (Postfix) with ESMTP id B89772E002C for ; Tue, 1 Apr 2008 19:23:57 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 75197-10 for ; Tue, 1 Apr 2008 19:23:48 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by developer.postgresql.org (Postfix) with ESMTP id A66A42E0074 for ; Tue, 1 Apr 2008 19:23:53 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id m31MNp6C015689; Tue, 1 Apr 2008 18:23:51 -0400 (EDT) To: "Hell, Robert" cc: pgsql-performance@postgresql.org Subject: Re: Cursors and different settings for default_statistics_target In-reply-to: References: <2798.1207063805@sss.pgh.pa.us> <9629.1207066619@sss.pgh.pa.us> <9999.1207068123@sss.pgh.pa.us> Comments: In-reply-to "Hell, Robert" message dated "Tue, 01 Apr 2008 23:12:58 +0200" Date: Tue, 01 Apr 2008 18:23:51 -0400 Message-ID: <15688.1207088631@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200804/16 X-Sequence-Number: 29509 "Hell, Robert" writes: > But why are the first 15 fetches (15360 rows) processed in 0.5 seconds and the last fetch (998 rows) takes 7 seconds. > Are we just unlucky that the last fetch takes that long? Well, the indexscan plan is going to scan through all the rows in objid order and return whichever of them happen to match the IN list. So I think you're just saying that your IN list isn't uniformly dense through the whole set of objids. If the real story is that you tend to select only objids within a narrow range, adding explicit "AND objid >= x AND objid <= y" constraints (where you compute x and y on the fly from the set of objids you're asking for) would reduce the overhead of the indexscan. regards, tom lane