Re: nextval() on serial using old, existing value on insert?

From: Wells Oliver <wells(dot)oliver(at)gmail(dot)com>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: pgsql-admin <pgsql-admin(at)postgresql(dot)org>
Subject: Re: nextval() on serial using old, existing value on insert?
Date: 2023-05-11 05:02:51
Message-ID: CAOC+FBWNpEvA9mSj3_wfhc2PPpeEr5BBshaN4trbXvgPgep0wQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Ah, I think that must be it-- there are 200 some rows where manually
supplied values for that common_key column are higher than the nextval() on
the serial. So eventually they might be "re-used".

On Wed, May 10, 2023 at 9:55 PM David G. Johnston <
david(dot)g(dot)johnston(at)gmail(dot)com> wrote:

>
> On Wednesday, May 10, 2023, Wells Oliver <wells(dot)oliver(at)gmail(dot)com> wrote:
>
>> I have a simple table with a given column defined like so:
>>
>> common_key | integer | | not null |
>> nextval('alias.identity_common_key_seq'::regclass) | plain
>>
>> Very very very infrequently, on an INSERT where this column is not
>> specified, this column will be assigned a value that already exists in the
>> table, versus the next presumably unused value in the sequence. I cannot
>> figure this out. Is there any reason why this might be the case?
>>
>
> Most likely someone inserted data without using the sequence and
> eventually the sequence catches up with that previously inserted data.
>
> David J.
>
>

--
Wells Oliver
wells(dot)oliver(at)gmail(dot)com <wellsoliver(at)gmail(dot)com>

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Wells Oliver 2023-05-11 05:06:28 Re: nextval() on serial using old, existing value on insert?
Previous Message David G. Johnston 2023-05-11 04:55:12 Re: nextval() on serial using old, existing value on insert?