Received: from localhost (unknown [200.46.204.184]) by developer.postgresql.org (Postfix) with ESMTP id DE5732E0066 for ; Tue, 1 Apr 2008 12:30:17 -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 73715-04 for ; Tue, 1 Apr 2008 12:30:08 -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 5D5552E0054 for ; Tue, 1 Apr 2008 12:30:08 -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 m31FU6Tl002799; Tue, 1 Apr 2008 11:30:06 -0400 (EDT) To: "Hell, Robert" cc: pgsql-performance@postgresql.org Subject: Re: Cursors and different settings for default_statistics_target In-reply-to: References: Comments: In-reply-to "Hell, Robert" message dated "Tue, 01 Apr 2008 14:14:25 +0200" Date: Tue, 01 Apr 2008 11:30:05 -0400 Message-ID: <2798.1207063805@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200804/7 X-Sequence-Number: 29500 "Hell, Robert" writes: > When we use 20 as default_statistics_target the retrieval of the data > takes 7.5 seconds - with 25 as default_statistics_target (with restart > and analyze) it takes 0.6 seconds. > The query plan is identical in both situations (row estimation differs a > little bit) - the query is always fast when it is executed without a > cursor. A cursor doesn't necessarily use the same plan as a straight query does. Try "EXPLAIN DECLARE curs_285058224 CURSOR FOR ..." and see if you aren't getting different plans in these two cases. regards, tom lane