Reputation: 477
My last record's primary key was 552 & when I added a new record it's primary key allotted is 584.
I'm surprised & would like to know possible reasons for this behavior.
Application Details :
Additional Info -> I'm using rails admin panel to add new record
Upvotes: 1
Views: 429
Reputation: 18474
Possible reasons:
Note: Because smallserial, serial and bigserial are implemented using sequences, there may be "holes" or gaps in the sequence of values which appears in the column, even if no rows are ever deleted. A value allocated from the sequence is still "used up" even if a row containing that value is never successfully inserted into the table column. This may happen, for example, if the inserting transaction rolls back.
table_name_seq
has increment
more than 1 (probably not your case, sometimes is useful for sharding)Upvotes: 4