Design innovative, scalable, and highly available cloud database solutions →hardMultiple ChoiceObjective-mapped
PCDE Practice Question: Design innovative, scalable, and highly available cloud database solutions
A team is designing a Cloud Spanner schema for a global social media application. The table 'Posts' has a primary key of (UserId, PostId) where PostId is a UUID. They notice write hotspots on the server with monotonically increasing UserId values. What is the most effective schema design change to distribute writes evenly?
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
✓
Add a hash prefix to the UserId to create a composite primary key like (HashUserId, UserId, PostId)
Using a hash prefix on the first part of the primary key (e.g., hash of UserId) helps distribute writes across splits, avoiding hotspots. Using a UUID for PostId is good but UserId ordering still causes hotspots. Adding a timestamp as a second part doesn't help. Interleaving with User is fine but doesn't fix the hotspot issue.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
Add a hash prefix to the UserId to create a composite primary key like (HashUserId, UserId, PostId)
Why this is correct
Hashing the UserId distributes writes across splits, reducing hotspots while allowing range scans on UserId after filtering.
- ✗
Create a secondary index on PostId
Why it's wrong here
Secondary indexes don't affect primary table write distribution; hotspots remain.
- ✗
Place PostId first in the primary key
Why it's wrong here
If PostId is UUID, it distributes writes, but the query pattern likely filters by UserId; reversing order may hurt performance.
- ✗
Use a monotonically increasing integer for PostId instead of UUID
Why it's wrong here
Monotonically increasing keys cause hotspots; UUIDs are better. This would worsen the problem.
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.