A company is designing a database schema for a global e-commerce platform. Orders are created with high frequency, and order status updates occur frequently. The team needs to choose a primary key strategy for the orders table in Spanner. Which approach minimizes hot-spotting?
Trap 1: Use a monotonically increasing integer (e.g., auto-increment)
Causes hot-spotting on the last split.
Trap 2: Use a timestamp as the primary key
Causes hot-spotting on the most recent timestamp split.
Trap 3: Use a composite key with user_id and order_date
If user_id is sequential or order_date is monotonically increasing, hot-spotting may still occur.
- A
Use a monotonically increasing integer (e.g., auto-increment)
Why wrong: Causes hot-spotting on the last split.
- B
Use a timestamp as the primary key
Why wrong: Causes hot-spotting on the most recent timestamp split.
- C
Use a composite key with user_id and order_date
Why wrong: If user_id is sequential or order_date is monotonically increasing, hot-spotting may still occur.
- D
Use a universally unique identifier (UUID) as the primary key
Distributes writes uniformly across splits.