Database / Google Spanner Database Interview questions
Why should you avoid monotonically increasing primary keys?
Because Spanner stores rows in primary-key order, a key that always increases, such as an auto-incrementing integer, a sequential ID, or a plain TIMESTAMP, means every new row is appended at the same end of the keyspace. That range becomes one split, and every insert competes for the same split's write capacity, creating a hotspot that no amount of extra nodes can relieve, since the other nodes simply sit idle.
The common fixes preserve uniqueness and rough ordering while breaking the monotonic pattern: bit-reverse a sequential ID before storing it, prepend a hash or a shard key derived from another column, or generate a UUID instead of a sequence. Each approach scatters new rows across many splits so writes parallelize across the full cluster instead of funneling through one.
More Related questions...