Re: sequences and "addval('myseq', value)" - Mailing list pgsql-hackers

From Tom Lane
Subject Re: sequences and "addval('myseq', value)"
Date
Msg-id 659.1086701713@sss.pgh.pa.us
Whole thread Raw
In response to Re: sequences and "addval('myseq', value)"  (pgsql@mohawksoft.com)
Responses Re: sequences and "addval('myseq', value)"  (pgsql@mohawksoft.com)
List pgsql-hackers
pgsql@mohawksoft.com writes:
> The question is, what do you think of an "addval" function for sequences.

It would have to be defined as "do the same thing as N successive
nextval calls would do", which would not be especially useful in the
presence of caching.

> The problem I, and I know many other people are having, is that large sums
> can not be obtained without a table scan. A summary table can be created,
> but if you have any sort of volume, you have to vacuum the summary table
> constantly.
> Using the sequence construct as sort of an accumulator just might fit the
> bill for this sort of thing.

How would it work at all?  Suppose your transaction rolls back after
doing the insert or update.  The table won't have changed ... but the
sequence change doesn't roll back.  You can't make such an easy end run
around the fundamental MVCC/locking problem.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Jan Wieck
Date:
Subject: Re: [GENERAL] The pgreplication project
Next
From: Fabien COELHO
Date:
Subject: cvs head : broken regression tests ?