Re: BUG #16554: Consistent sequence gaps occuring next day

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: toamitahuja(at)yahoo(dot)co(dot)in
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #16554: Consistent sequence gaps occuring next day
Date: 2020-07-25 14:42:59
Message-ID: 672931.1595688179@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

PG Bug reporting form <noreply(at)postgresql(dot)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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Jehan-Guillaume de Rorthais 2020-07-25 21:43:28 Re: Buffers from parallel workers not accumulated to upper nodes with gather merge
Previous Message Tom Lane 2020-07-25 14:35:30 Re: subquery column error causes data destroying equality