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>
Cc: 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 09:47:17 -0700
Message-ID: <2c994f4f-6627-1c4d-fac5-d3c442d197e9@aklaver.com> (raw)
In-Reply-To: <CAEjudX5Zq=do9ZGUR-hFPGYp31hCSQUr20ifkeDOUywZpAngjw@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>
	<CAEjudX5Zq=do9ZGUR-hFPGYp31hCSQUr20ifkeDOUywZpAngjw@mail.gmail.com>

On 3/20/20 8:13 PM, pabloa98 wrote:
> 
>     Nothing I saw that said int could not become bigint.
> 
> 
> My bad. The code cannot be a bigint. Or it could be a bigint between 1 
> to 99999999 :)


Aah, that was the counter Peter was talking about. I missed that.

As to below that is going to require more thought.

> I thought it was not important. The code could be a number from 1 to 
> 99999999 (so an Int will be OK) assigned in order-ish. This is because 
> of business requirements. The code should not change in case a row is 
> deleted. That rules out using windowed functions. At least for this 
> problem. There could be some gaps if they are not too big (similar to a 
> serial column when a transaction is rolled back). We are more concerned 
> about code generation collisions (for example 2 transactions calculating 
> the same code value) than gaps. For each pair (group, element) the code, 
> once assigned should remain constant. This is because the group, the 
> element, and the code will become an id (business-related). So:
> 
> group, element, code = bid
> 1, 3, 1 = bid 131
> 2, 1, 1 = bid 211
> etc
> 
> This calculated bid follows the convention described here and it is used 
> as a reference in other tables. Therefore it should not change.
> All this weirdness is because of business requirements. I am good with a 
> classic serial column. But that will not map our business rules.
> 
> Regarding to the implementation of this. Our concern is to choose 
> something not slow (it does not need to be super fast because there will 
> be more operations in other tables using the same transaction) and I 
> thought that creating/dropping sequences could be a solution. But I was 
> not sure. I am not sure how it will behave with millions of sequences.
> 
> If there is another solution different than millions of sequences that 
> do not block, generate few gaps (and those gaps are small) and never 
> generate collisions then I will happily use it.
> 
> I hope I described the problem completely.
> 
> Pablo
> 
> 
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com





view thread (58+ messages)  latest in thread

Message-ID: <2c994f4f-6627-1c4d-fac5-d3c442d197e9@aklaver.com>
Permalink:  ../2c994f4f-6627-1c4d-fac5-d3c442d197e9@aklaver.com/
Also on:    postgresql.org/message-id/2c994f4f-6627-1c4d-fac5-d3c442d197e9@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: <2c994f4f-6627-1c4d-fac5-d3c442d197e9@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> <CAEjudX5Zq=do9ZGUR-hFPGYp31hCSQUr20ifkeDOUywZpAngjw@mail.gmail.com> <2c994f4f-6627-1c4d-fac5-d3c442d197e9@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