Can too high an ID (auto-increment) be harmful?

Asked

Viewed 698 times

3

I have a table that has a very high turnover of information, that is, many records enter and many leave as well. With this the ID (auto-increment) is much higher than the value of data in the table.

For example, the table is with 530 records and the ID (auto-increment) is at 1250, and these numbers tend to increase relatively quickly.

I wonder if this might cause some slowness or it might be bad in some way for my database and my application. If it causes any trouble, what can I do to make it better?

Note: I don’t know if it changes anything, but the Ids of this table are foreign keys in other tables.

1 answer

5


In postgres the auto-increment field is called Sequence, an id with high number does not cause slowness in a query, the problem that can happen is that field (int maybe) quickly reach its limit in which case it would be necessary to exchange for a higher capacity type like bigint.

A curious fact that happens a while back was the viz counter of youtube pop up after that, began to appear a negative number of views on Psy video.

Excerpt taken from How 'Gangnam Style' blew the Youtube counter

The Youtube counter until now used a 32-bit marker, unit that represents the data in the computational architecture.

This means that the maximum number of visits that could be recorded was 2,147,483,647.

  • got it, and the maximum number my Quence being an int field can reach is 2,147,483,647? That’s what I found in a survey.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.