Re:Postgres sequences can skip 32 unexpectedly
by merb on Thursday July 15, 2021 @03:50PM
(#27849279)
btw. it's easy to use FOR UPDATE to create custom sequences in a table that do not have the batch reservation feature. it's just slower if you can afford that.
the problem with resetting the sequence is that it would need a full blown serilizable transaction which is worse thatn just using for update and read commited.
[ Parent
| on HN ]
Re:Postgres sequences can skip 32 unexpectedly
by combatentropy on Thursday July 15, 2021 @06:34PM
(#27850909)
Right. It isn't something I recommend running in production before every insert. It's just something I have done sometimes, like as part of a big database change, and only to "reference" tables. Like suppose there is a table of 10 rows to populate a dropdown menu. Now I need to add an 11th, but for some reason the sequence got out of wack, and the next sequence value is 15. So I manually set it back to 11.