Google Cloud Professional Data Engineer — Question 332
You need to create a new transaction table in Cloud Spanner that stores product sales data. You are deciding what to use as a primary key. From a performance perspective, which strategy should you choose?
Answer options
- A. The current epoch time
- B. A concatenation of the product name and the current epoch time
- C. A random universally unique identifier number (version 4 UUID)
- D. The original order identification number from the sales system, which is a monotonically increasing integer
Correct answer: C
Explanation
Using a random universally unique identifier number (version 4 UUID) as a primary key helps to distribute writes evenly across the database, which enhances performance. In contrast, the current epoch time and a concatenation with product name can lead to clustering of writes, while a monotonically increasing integer may cause hot-spotting, leading to performance bottlenecks.