Re: BUG #16554: Consistent sequence gaps occuring next day - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #16554: Consistent sequence gaps occuring next day
Date
Msg-id 672931.1595688179@sss.pgh.pa.us
Whole thread Raw
In response to BUG #16554: Consistent sequence gaps occuring next day  (PG Bug reporting form <noreply@postgresql.org>)
List pgsql-bugs
PG Bug reporting form <noreply@postgresql.org> writes:
> It has been observed that the sequences are starting with a gap of around 30
> ( more or less) the next day. The sequences are generated sequentially
> (continuous with no gaps) on/within the same day. However once the
> application/server is stopped and restarted the next day , the sequence
> starts with a gap ( mostly around 30 or may be 10 , 20 etc).

This is expected behavior, as a result of optimization to reduce the
amount of WAL traffic generated by nextval calls.  The optimization
is not user-adjustable (cf. SEQ_LOG_VALS in sequence.c).

It's not particularly worth doing something about it, because if your
application requires a gapless sequence, you cannot use Postgres
sequence objects to get that anyway.  Transactions that roll back
after executing a nextval() will also cause gaps.

            regards, tom lane



pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: subquery column error causes data destroying equality
Next
From: Jehan-Guillaume de Rorthais
Date:
Subject: Re: Buffers from parallel workers not accumulated to upper nodes with gather merge