pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: pabloa98 <pabloa98@gmail.com>
To: Peter J. Holzer <hjp-pgsql@hjp.at>
Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: Could postgres12 support millions of sequences? (like 10 million)
Date: Sat, 21 Mar 2020 16:36:56 -0700
Message-ID: <9ef7e0ea-1314-290a-d0ee-cbcd095e8e41@aklaver.com> (raw)
In-Reply-To: <CAEjudX7xNi-YjkkmN4Gy5dTVFBX05ak87iFcD48M0PzF_WrDZw@mail.gmail.com>
References: <20200320225842.GA18976@hjp.at>
	<0D8F2D62-C0E4-4D6C-B77C-9A2FEB78898C@gmail.com>
	<20200320232929.GA22868@hjp.at>
	<03223774-abab-f2c8-9f7c-824eb545a401@aklaver.com>
	<20200321190758.GA5473@hjp.at>
	<CAEjudX7xNi-YjkkmN4Gy5dTVFBX05ak87iFcD48M0PzF_WrDZw@mail.gmail.com>

On 3/21/20 1:45 PM, pabloa98 wrote:
> 
> 
> On Sat, Mar 21, 2020 at 12:08 PM Peter J. Holzer <hjp-pgsql@hjp.at 
> <mailto:hjp-pgsql@hjp.at>> wrote:
> 
> 
> 
>     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.
> 
> 
> OK. In that case, I will proceed with the millions of sequences. We will 
> see.
> 
> Anyway, It will be awesome if we have a sequence data type in a future 
> version of postgresql. They will solve a lot of problems similar to this 
> one.

Actually there are already two:

https://www.postgresql.org/docs/12/datatype-numeric.html#DATATYPE-SERIAL

https://www.postgresql.org/docs/12/sql-createtable.html
"
GENERATED { ALWAYS | BY DEFAULT } AS IDENTITY [ ( sequence_options ) ]

     This clause creates the column as an identity column. It will have 
an implicit sequence attached to it and the column in new rows will 
automatically have values from the sequence assigned to it.
"

What you want is a built in method to pull from different sequences 
depending on the value of another column or values from multiple columns 
in the same table.


> 
> Pablo
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com





view thread (58+ messages)  latest in thread

Message-ID: <9ef7e0ea-1314-290a-d0ee-cbcd095e8e41@aklaver.com>
Permalink:  ../9ef7e0ea-1314-290a-d0ee-cbcd095e8e41@aklaver.com/
Also on:    postgresql.org/message-id/9ef7e0ea-1314-290a-d0ee-cbcd095e8e41@aklaver.com

 · 

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-general@postgresql.org
  Cc: adrian.klaver@aklaver.com, pabloa98@gmail.com, hjp-pgsql@hjp.at
  Subject: Re: Could postgres12 support millions of sequences? (like 10 million)
  In-Reply-To: <9ef7e0ea-1314-290a-d0ee-cbcd095e8e41@aklaver.com>
  References: <20200320225842.GA18976@hjp.at> <0D8F2D62-C0E4-4D6C-B77C-9A2FEB78898C@gmail.com> <20200320232929.GA22868@hjp.at> <03223774-abab-f2c8-9f7c-824eb545a401@aklaver.com> <20200321190758.GA5473@hjp.at> <CAEjudX7xNi-YjkkmN4Gy5dTVFBX05ak87iFcD48M0PzF_WrDZw@mail.gmail.com> <9ef7e0ea-1314-290a-d0ee-cbcd095e8e41@aklaver.com>

* 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