Re: Two sequences associated with one identity column

From: "Colin 't Hart" <colinthart(at)gmail(dot)com>
To: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
Cc: PostgreSQL General <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Two sequences associated with one identity column
Date: 2025-10-30 08:55:12
Message-ID: CAMon-aQNPQ86-swjmpiryy3s_yKaWsZbzysrbn7e1xPc3JM3fg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-general

relname | relnamespace | relpersistence
--------------------------+--------------+----------------
<sequence1> | 524799410 | p
<sequence2> | 524799410 | p
(2 rows)

On Wed, 29 Oct 2025 at 17:28, Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> wrote:
>
> On 10/29/25 06:40, Colin 't Hart wrote:
> > As expected the dump contains:
> >
> > CREATE TABLE <schema>.<tablename> (
> > <other columns>,
> > id bigint NOT NULL
> > );
> >
> > <snip>
> >
> > --
> > -- Name: <sequence1>; Type: SEQUENCE; Schema: <schema>; Owner: <owner>
> > --
> >
> > ALTER TABLE <schema>.<tablename> ALTER COLUMN id ADD GENERATED ALWAYS
> > AS IDENTITY (
> > SEQUENCE NAME <schema>.<sequence1>
> > START WITH 1
> > INCREMENT BY 1
> > NO MINVALUE
> > NO MAXVALUE
> > CACHE 1
> > );
> >
> >
> > --
> > -- Name: <sequence2>; Type: SEQUENCE; Schema: <schema>; Owner: <owner>
> > --
> >
> > ALTER TABLE <schema>.<tablename> ALTER COLUMN id ADD GENERATED ALWAYS
> > AS IDENTITY (
> > SEQUENCE NAME <schema>.<sequence2>
> > START WITH 1
> > INCREMENT BY 1
> > NO MINVALUE
> > NO MAXVALUE
> > CACHE 1
> > );
>
> Just a wild guess. Assuming <schema> is the same, what is the output of:
>
> SELECT
> relname,
> relnamespace,
> relpersistence
> FROM
> pg_class
> WHERE
> relname IN ('<sequence1>', '<sequence2> ')
> AND relnamespace = '<schema>'::regnamespace;
>
>
> >
>
> > /Colin
> >
>
> --
> Adrian Klaver
> adrian(dot)klaver(at)aklaver(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2025-10-30 14:42:26 Re: Two sequences associated with one identity column
Previous Message Jacob Jackson 2025-10-30 00:09:14 Re: Postgres memoizing inner loop of join when outer loop join key is guaranteed unique?