pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: David Johnston <polobo@yahoo.com>
Cc: pgsql-bugs@postgresql.org
Subject: Re: Re: BUG #8448: looping through query results exits at 10th step under some conditions
Date: Tue, 12 Nov 2013 17:06:58 -0500
Message-ID: <14791.1384294018@sss.pgh.pa.us> (raw)
In-Reply-To: <1384292093855-5777999.post@n5.nabble.com>
References: <E1VK84r-0004zz-33@wrigleys.postgresql.org>
	<11851.1384285210@sss.pgh.pa.us>
	<1384292093855-5777999.post@n5.nabble.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

David Johnston <polobo@yahoo.com> 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



view thread (4+ messages)

Message-ID: <14791.1384294018@sss.pgh.pa.us>
Permalink:  ../14791.1384294018@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/14791.1384294018@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, polobo@yahoo.com
  Subject: Re: BUG #8448: looping through query results exits at 10th step under some conditions
  In-Reply-To: <14791.1384294018@sss.pgh.pa.us>
  References: <E1VK84r-0004zz-33@wrigleys.postgresql.org> <11851.1384285210@sss.pgh.pa.us> <1384292093855-5777999.post@n5.nabble.com> <14791.1384294018@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox