
Explanation:
The correct answer is to change the primary key to avoid monotonically increasing values. This is because using a column with values that increase sequentially (like person_id) as the primary key can lead to hotspots in your database. Hotspots occur when all inserts are directed to a single server due to the key range distribution in Cloud Spanner, causing performance bottlenecks.
Reference: Cloud Spanner Schema Design - Preventing Hotspots
The other options do not address the root cause of the performance issue, which is the sequential nature of the primary key values.
Ultimate access to all questions.
No comments yet.
Your customer has implemented a solution using Cloud Spanner and is experiencing read latency-related performance issues on a specific table. This table is accessed solely by their users via a primary key. The table's schema is as follows:
CREATE TABLE Persons (
person_id INT64 NOT NULL, // sequential number based on number of registrations
account_creation_date DATE, // system date
birthdate DATE, // customer birthdate
firstname STRING (255), // first name
lastname STRING (255), // last name
profile_picture BYTES (255) // profile picture
) PRIMARY KEY (person_id)
CREATE TABLE Persons (
person_id INT64 NOT NULL, // sequential number based on number of registrations
account_creation_date DATE, // system date
birthdate DATE, // customer birthdate
firstname STRING (255), // first name
lastname STRING (255), // last name
profile_picture BYTES (255) // profile picture
) PRIMARY KEY (person_id)
What action should you take to resolve the performance issue?
A
Remove the profile_picture field from the table.
B
Add a secondary index on the person_id column.
C
Change the primary key to avoid monotonically increasing values.
D
Create a secondary index using the following Data Definition Language (DDL):
CREATE INDEX person_id_ix
ON Persons (
person_id,
firstname,
lastname
) STORING (
profile_picture
)
CREATE INDEX person_id_ix
ON Persons (
person_id,
firstname,
lastname
) STORING (
profile_picture
)