0

I have a Django application deployed on Heroku (free dyno) and I use Heroku Postgres as my database (Hobby Tier).

I been noticing that sometimes there are some gaps/jumps on the primary key numeration. For example, there was a jump from 162 to 195, from 237 to 270... But objects are not deleted in between this gaps. I can't really understand why this is happening.

Has anyone experienced something similar? What do you think? Is this problem related to Django, Postgres or Heroku?

Sofia
  • 445
  • 4
  • 17
  • 3
    [Sequences](https://www.postgresql.org/docs/current/sql-createsequence.html) are not guaranteed to be gapless. Read the information in the section *Notes* at the linked docs to see why. FYI, sequences are also used by `GENERATED { ALWAYS | BY DEFAULT } AS IDENTITY ` when creating a table. – Adrian Klaver Mar 17 '22 at 22:09
  • Yes, I guess so. Thank you @AdrianKlaver. This [Postgres Wiki](https://wiki.postgresql.org/wiki/FAQ#Why_are_there_gaps_in_the_numbering_of_my_sequence.2FSERIAL_column.3F_Why_aren.27t_my_sequence_numbers_reused_on_transaction_abort.3F) was also useful – Sofia Mar 18 '22 at 08:20

0 Answers0