Re: sequence caches

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: jks(at)selectacast(dot)net
Cc: pgsql-general(at)postgresql(dot)org, Rod Taylor <rbt(at)rbt(dot)ca>
Subject: Re: sequence caches
Date: 2003-05-20 18:09:14
Message-ID: 460.1053454154@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

jks(at)selectacast(dot)net writes:
>> Seems that would require predicting the future. How would you know how
>> many times the sequence would get nextval'd in one query?

> Because you parse the query before you take any action, so you know how
> many times the nextval will be called.

No you don't. Consider CASE expressions, SELECTs that will return an
uncertain number of rows, etc.

> Or do you do the locking down in
> the nextval method that knows nothing about the other nextvals?

Exactly.

> Perhaps
> there could be a function call that retrieves X sequence numbers from the
> sequence that overrides the cache settings so I could query like:
> SELECT nextval('seqname',3),nextval('seqname'),nextval('seqname');

Doesn't really seem worth the trouble to me. To take just one obvious
problem, what makes you think that those expressions will be evaluated
left-to-right? There are no guarantees of execution order in SQL.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Rod Taylor 2003-05-20 18:13:11 Re: sequence caches
Previous Message jks 2003-05-20 18:02:56 Re: sequence caches