Design innovative, scalable, and highly available cloud database solutions →hardMultiple ChoiceObjective-mapped
PCDE Practice Question: Design innovative, scalable, and highly available cloud database solutions
You need to design a Spanner schema for a social media application that stores user posts. Each post has a unique ID, author ID, timestamp, and content. The primary access pattern is querying all posts for a given author in reverse chronological order. Which schema design minimizes the risk of hotspotting?
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Primary key: (AuthorId, PostId) where PostId is generated using a UUID
Using a composite primary key with AuthorId as the first part distributes writes across splits. However, adding Timestamp as the second key causes monotonically increasing writes for a single author, leading to hotspotting on the last split. Instead, a random component like a UUID (as in option A) distributes writes evenly across splits, minimizing hotspot risk. Option A's UUID provides sufficient randomness to avoid sequential writes while still enabling efficient queries per author via the prefix.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
Primary key: (AuthorId, PostId) where PostId is generated using a UUID
Why this is correct
Correct. The UUID as the second part of the key ensures writes are distributed randomly across splits, avoiding hotspotting, while the AuthorId prefix supports efficient reverse-chronological queries (by ordering on PostId, which is random, not chronological; but the access pattern is querying all posts for an author, which can be done by scanning the AuthorId prefix; reverse chronological order can be achieved by storing timestamps in a separate column and ordering by that during query, or by using a descending index on timestamp). The primary purpose here is to minimize hotspotting.
- ✗
Primary key: (AuthorId, HashOfPostId)
Why it's wrong here
HashOfPostId is not monotonic but prevents natural ordering by time, requiring additional sorting.
- ✗
Primary key: (AuthorId, Timestamp) with Timestamp stored in descending order
Why it's wrong here
Incorrect. Although the composite key distributes across authors, for a high-volume author, the timestamp is monotonically increasing, causing all new writes to land on the same split (the last one), which creates a hotspot. This contradicts the goal of minimizing hotspotting.
- ✗
Primary key: (PostId) with a secondary index on AuthorId
Why it's wrong here
Sequential PostId as primary key leads to hotspotting on a single split.
Go deeper
Related to this question
About these practice questions
One of 1,446 original PCDE practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This PCDE practice question is part of Courseiva's free Google Cloud certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the PCDE exam.