Could postgres12 support millions of sequences? (like 10 million) - Mailing list pgsql-general

From pabloa98
Subject Could postgres12 support millions of sequences? (like 10 million)
Date
Msg-id CAEjudX5UdEYJwSTYir07rUX10u3AdEyht_K=GWk_CyOChSFguQ@mail.gmail.com
Whole thread Raw
Responses Re: Could postgres12 support millions of sequences? (like 10 million)  (Rob Sargent <robjsargent@gmail.com>)
Re: Could postgres12 support millions of sequences? (like 10million)  (rob stone <floriparob@gmail.com>)
List pgsql-general
Hello,

My schema requires a counter for each combination of 2 values. Something like:

CREATE TABLE counter(
group INT NOT NULL,
element INT NOT NULL,
seq_number INT NOT NULL default 0,
CONSTRAINT PRIMARY KEY (group, element)
);

For each entry in counter, aka for each (group, element) pair, the model requires a seq_number.

If I use a table "counter", I could still have counter collisions between 2 transactions. I need truly sequence behavior. Is that possible by using a table like "counter" table, where the counter could be increased out of the transaction so it performs as a sequence without having race conditions between concurrent transactions?

The other option is to create sequences for each new pair of (group, element) using triggers. There are millions of pairs. So this approach will generate millions of sequences.

How a PostgreSQL database would behave having millions of sequences in a schema? Would it degrade its performance? Is there any negative impact?

Regards

Pablo



pgsql-general by date:

Previous
From: Justin King
Date:
Subject: Re: Fwd: PG12 autovac issues
Next
From: Rob Sargent
Date:
Subject: Re: Could postgres12 support millions of sequences? (like 10 million)