Fixing holes/gaps in numbers generated by Postgres sequence

前端 未结 3 1362
误落风尘
误落风尘 2020-12-21 12:35

I have a postgres database that uses sequences extensively to generate primary keys of tables. After a lot of usage of this database i.e. Adding/Update/Delete operation the

3条回答
  •  伪装坚强ぢ
    2020-12-21 13:10

    It is possible to solve this problem, but is expensive for the database to do (especially IO) and is guaranteed to reoccur. I would not worry about this problem. If you get close to 4B, upgrade your primary and foreign keys to BIGSERIAL and BIGINT. If you're getting close to 2^64... well... I'd be interested in hearing more about your application. :~]

提交回复
热议问题