Question

Is there a maximum value as to how high pk values for a model can get? For example, for something like an activity feed model, the pk's can get really large.

Ex, "Kyle liked this post", "Alex commented on this post" etc..As you can see, for every action, an activity feed object is created. Is there some sort of maximum threshold that will be reached? I've done some research but haven't found a concise answer. If there is some limit, how can one overcome this?

I currently use PostgreSQL as my database.

Était-ce utile?

La solution

Django's auto-incrementing IDs are AutoFields, a subclass of IntegerField. It will generate the primary keys as PostgreSQL integer, which are signed 32-bit integers with a maximum value of 2147483647, a little over 2 billion.

Autres conseils

I'm gonna take a guess and assume that postgreSQL stores primary keys as 64 bits unsigned integers. If this is the case, then you can have up to 2^64 different values. Even with a 32 bits integer, that leaves us with 4294967296 possibilities. Unless you are twitter or facebook, you should never be annoyed with this kind of limit.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top