-
Notifications
You must be signed in to change notification settings - Fork 468
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Recommend against using autoincremented integer primary keys #3420
Comments
Also, this FAQ entry on generated IDs should be updated to deemphasize / discourage |
Fixes #4183, #4254. Addresses part of #3420, #4298. Summary of changes: - Add `default_int_size` to session vars page - Update `INT` data type page with new subsections of the **Size** section: - Description of compatibility issues caused by 64-bit integers vs. e.g. JavaScript runtimes, including when using autogenerated JS clients - Why you should avoid integer primary keys, with links to more information in Perf Best Practices and the Architecture docs
I drafted this recently while working on updates to the Integer primary keysIf you are planning to use a primary key of type If |
... unless it's absolutely necessary for a specific use case, in which case you should be aware of the effects on
INSERT
performance (and possibly time required for range rebalancing across nodes? I'm much murkier on this point).We do mention this issue obliquely in the performance best practices docs, but in terms of general transaction contention.
However, this issue keeps coming up in the forum in one guise or another:
Therefore, in addition to our current docs on this issue, we should state explicitly in the primary key docs, the CREATE TABLE docs, and possibly others that most users should use random values as primary keys most of the time. Users who are aware of and OK with the tradeoffs that will result from using sequential values can still do so of course, but we should describe those tradeoffs.
Perhaps a variation of @knz's comment on the last forum post in the list above would suffice, i.e.,
(Aside: the latter point about read latency may be mitigated somewhat in a magical follower reads future, AIUI, but that is beside the point at this time.)
(cc @tim-o FYI)
The text was updated successfully, but these errors were encountered: