Re: Could postgres12 support millions of sequences? (like 10 million)

From: "Peter J(dot) Holzer" <hjp-pgsql(at)hjp(dot)at>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Could postgres12 support millions of sequences? (like 10 million)
Date: 2020-03-21 19:07:58
Message-ID: 20200321190758.GA5473@hjp.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 2020-03-20 17:53:11 -0700, Adrian Klaver wrote:
> On 3/20/20 4:29 PM, Peter J. Holzer wrote:
> > On 2020-03-20 17:11:42 -0600, Rob Sargent wrote:
> > > On Mar 20, 2020, at 4:59 PM, Peter J. Holzer <hjp-pgsql(at)hjp(dot)at> wrote:
> > > > On 2020-03-19 16:48:19 -0700, David G. Johnston wrote:
> > > > > First, it sounds like you care about there being no gaps in the records you end
> > > > > up saving. If that is the case then sequences will not work for you.
> > > >
> > > > I think (but I would love to be proven wrong), that *nothing* will work
> > > > reliably, if
> > > >
> > > > 1) you need gapless numbers which are strictly allocated in sequence
> > > > 2) you have transactions
> > > > 3) you don't want to block
[...]
> > Yes. This wasn't a response to the OP's requirements, but to David's
> > (rather knee-jerk, IMHO) "don't use sequences" response. Very often the
> > requirements which would preclude sequences also preclude any other
> > solution.
>
> I don't see a knee-jerk reaction in this:
>
> https://www.postgresql.org/message-id/CAKFQuwZ%3D%3Dri5_m2geFA-GPOdfnVggmJRu3zEi%2B1EwJdJA%3D9AeQ%40mail.gmail.com
>
> The response was if you cared about gaps(not something the OP had specified
> at that point) then a sequence would not work.

And I think that "care about gaps -> sequence doesn't work" is a
knee-jerk reaction. It's similar to "can't parse HTML with regexps".
True in the general case, and therefore people tend to blurt it out
every time the topic comes up. But not necessarily true in specific
cases. As I wrote above, there is no perfect solution - so you have to
think about the actual requirements and the consequences of various
solutions - and maybe using a sequence is the best (or least bad)
solution.

hp

--
_ | Peter J. Holzer | Story must make more sense than reality.
|_|_) | |
| | | hjp(at)hjp(dot)at | -- Charles Stross, "Creative writing
__/ | http://www.hjp.at/ | challenge!"

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2020-03-21 19:11:25 Re: Duplicate key violation on upsert
Previous Message Rob Sargent 2020-03-21 18:55:33 Re: Could postgres12 support millions of sequences? (like 10 million)