Reputation: 259
Does Cloud Spanner support an AUTOINCREMENT Field so that a unique number is generated when a new record is inserted into a table?
Upvotes: 1
Views: 1942
Reputation: 408
Cloud Spanner doesn't have that feature. Using sequential for primary key is even an anti-pattern because it creates hotspot.
If you insert records with a monotonically increasing integer as the key, you'll always insert at the end of your key space. This is undesirable because Cloud Spanner divides data among servers by key ranges, which means your inserts will be directed at a single server, creating a hotspot.
https://cloud.google.com/spanner/docs/schema-and-data-model#choosing_a_primary_key
Upvotes: 2