Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VgM6x-0004fU-JS for pgsql-bugs@arkaria.postgresql.org; Tue, 12 Nov 2013 22:07:03 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VgM6x-0004vT-1D for pgsql-bugs@arkaria.postgresql.org; Tue, 12 Nov 2013 22:07:03 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VgM6v-0004uQ-UC for pgsql-bugs@postgresql.org; Tue, 12 Nov 2013 22:07:01 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VgM6t-0003ev-9e for pgsql-bugs@postgresql.org; Tue, 12 Nov 2013 22:07:01 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id rACM6wqE014792; Tue, 12 Nov 2013 17:06:58 -0500 From: Tom Lane To: David Johnston cc: pgsql-bugs@postgresql.org Subject: Re: Re: BUG #8448: looping through query results exits at 10th step under some conditions In-reply-to: <1384292093855-5777999.post@n5.nabble.com> References: <11851.1384285210@sss.pgh.pa.us> <1384292093855-5777999.post@n5.nabble.com> Comments: In-reply-to David Johnston message dated "Tue, 12 Nov 2013 13:34:53 -0800" Date: Tue, 12 Nov 2013 17:06:58 -0500 Message-ID: <14791.1384294018@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org David Johnston writes: > So, is there an underlying use-case driving this complaint that should be > considered by the community either to induce a fix to the behavior or just > to solicit suggestions for better alternatives? While I agree the specific test case presented isn't terribly compelling, it's not that hard to think of other scenarios where somebody might be surprised at the presence of prefetching. Consider perhaps the requirement "give me the next value from sequence s1 that's divisible by ten". On its face this doesn't seem like a terrible implementation: for s in select nextval('s1') from generate_series(1,10) loop if s % 10 = 0 then exit loop; end if; end loop; This will do what's asked for but it will typically increment the sequence several extra times due to internal prefetching. Perhaps the application can tolerate that, perhaps not. With a user-defined volatile function, the unwanted side effects might be quite unacceptable. Anyway, I'm not hugely motivated to change the code to fix this, but I think we at least ought to document it. regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs