| From: | Michael Paquier <michael(at)paquier(dot)xyz> |
|---|---|
| To: | Andrei Lepikhov <lepihov(at)gmail(dot)com> |
| Cc: | Peter Eisentraut <peter(at)eisentraut(dot)org>, Kirill Reshke <reshkekirill(at)gmail(dot)com>, Peter Smith <smithpb2250(at)gmail(dot)com>, Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: Sequence Access Methods, round two |
| Date: | 2025-11-11 01:43:42 |
| Message-ID: | aRKUzt0MOHPooEem@paquier.xyz |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Mon, Nov 10, 2025 at 04:31:07PM +0100, Andrei Lepikhov wrote:
> In multimaster, you may find an implementation of strictly monotone
> sequences. This method is covered by a GUC, impolitely named as 'Volkswagen
> method'.
I'm afraid that I cannot understand what you mean with this reference.
> However, it adds a massive overhead and is designed only for very
> narrow cases.
Are you referring to the function redirections required for the
callbacks here? Or are you referring to something more specific?
> I skimmed your patches. It seems that 0003 and 0007 should be the first
> patches in the set.
Patch 0003 is named "Sequence access methods - backend support",
relying on two refactoring pieces. Patch 0007 is the snowflake
contrib module, which is based on all the other patches. So I don't
quite see what would be the point here based on how the patch is
currently written?
> Additionally, the approach itself appears overly complicated to me.
> Generally, I need a kinda of type parameter (like typmod) where I can
> propose the OID of the nextval routine and extra parameters - it may be
> serialised somewhere in pg_attribute.
> It seems even more flexible than a default_sequence_access_method, doesn't
> it?
Hmm. How would this fit into a DDL model? The advantage of the GUC
is to be able to hide from the client which sequence computation
method is used internally, with something like the following to forget
about the knowledge of the computation, so as it's fully transparent:
CREATE ACCESS METHOD popo
TYPE SEQUENCE HANDLER popo_sequenceam_handler;
SET default_sequence_access_method = popo;
CREATE TABLE tab (a int GENERATED ALWAYS AS IDENTITY, b int);
It seems to me that you are proposing something slightly different,
then with an extra option, say a sort of "COMPUTATION" clause for
CREATE TABLE's sequence_options or CREATE SEQUENCE, where the name of
the function to use would be given to bypass nextval(). I don't
really get how this solves the transparency argument, because we'd
still need to update all the schemas to use something a different
function for the nextval(), no? It would not deal with a bunch of
other states, like how we fetch sequence meta-data on upgrades, for
the new logical decoding feature where we may want a page LSN, and
setval(). lastval() remains the easy one as we just need to cache the
last 8-byte value, and we maintain the name of the sequence in a
static cache for each backend.
Anyway, there are also two more properties related to the in-core
sequences where the cases I have seen do not want to deal with:
- WAL generation, currently tracked by log_cnt, or be able to bypass
entirely WAL, or control the rate of the records.
- Storage, where no local storage is required for sequences.
It sounds like your case does really care much about these dealing
with these, where you would only need a shortcut to pass a nextval()
for a sequence, but I cannot say for sure if these two properties
matter for you, as well.
--
Michael
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Yugo Nagata | 2025-11-11 01:50:37 | Re: Suggestion to add --continue-client-on-abort option to pgbench |
| Previous Message | Joshua Shanks | 2025-11-11 01:21:00 | Re: [PATCH] libpq: Wrap out-of-memory error messages with libpq_gettext() |