
Answer-first summary for fast verification
Answer: Ensure the primary key values are not monotonically increasing.
**Correct Answer: C** Ensuring the primary key does not have monotonically increasing values can alleviate read latency by preventing hotspotting, where operations concentrate on a few nodes, thus distributing the workload more evenly. **Why Not Others?** - **A:** Removing the `profile_picture` field, a byte type storing binary data like images, doesn't directly improve read latency. - **B:** Adding a secondary index on `person_id` is ineffective since queries use the primary key, not `person_id`. - **D:** Creating a secondary index via DDL doesn't address the core issue of primary key access patterns causing latency. For further reading on schema design and primary key selection in Cloud Spanner, consider these resources: - [Cloud Spanner Schema Design](https://cloud.google.com/spanner/docs/schema-design) - [Choosing the Right Primary Keys in Cloud Spanner](https://medium.com/google-cloud/cloud-spanner-choosing-the-right-primary-keys-cd2a47c7b52d)
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
You are managing a globally accessible apparel website using Cloud Spanner. Despite the global reach, you've encountered read latency issues on a specific table accessed solely via its primary key. The table's schema is as follows:
CREATE TABLE Users (
user_id INT64 NOT NULL, // Sequential number based on registration
account_creation_date DATE, // System date
firstname STRING(255), // First name
lastname STRING(255), // Last name
birthdate DATE, // User birthdate
profile_picture BYTES(255) // User profile picture
) PRIMARY KEY (user_id)
CREATE TABLE Users (
user_id INT64 NOT NULL, // Sequential number based on registration
account_creation_date DATE, // System date
firstname STRING(255), // First name
lastname STRING(255), // Last name
birthdate DATE, // User birthdate
profile_picture BYTES(255) // User profile picture
) PRIMARY KEY (user_id)
What action should you take to mitigate these performance issues?
A
Remove the profile_picture field to enhance performance.
B
Introduce a secondary index on the person_id column.
C
Ensure the primary key values are not monotonically increasing.
D
Utilize Data Definition Language (DDL) to establish a secondary index and access it through the primary key.
No comments yet.