Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #4491. There are two good options for this, each with tradeoffs. One is for SERIAL to be an alias for DEFAULT unique_rowid and the other is to emulate Postgres's SEQUENCEs. Emulating SEQUENCE funnels every insert through a single point of contention, but would be a drop-in replacement. unique_rowid has no contention, is faster, and works for the common use of a unique and increasing identifier (modulo overlapping transactions). Unfortunately, it may also cause user confusion and break ORMs that (correctly in Postgres) assume that SERIAL starts at 0 and (incorrectly) that SERIAL has no holes. An interesting side benefit of unique_rowid is that it prevents the problem of inadvertantly exposing user growth numbers (sign up for a service once per day and keep track of the userids), which is a common issue with SERIAL. If it was known that user confusion and ORM compatibility would not be an issue, unique_rowid would be the clear decision. Since it's still early enough to run small experiments, this is the approach used here. If this results in sufficient evidence that it was the wrong decision, a later version of Cockroach will switch the behavior to emulate SEQUENCEs. Existing SERIAL columns will, however, retain the old behavior.
- Loading branch information