Google Cloud Professional Cloud Database Engineer — Question 156
You are migrating your on-premises PostgreSQL database to Spanner. You need to identify a solution for handling existing integer-based table primary keys. You want minimal changes to the applications while also following Google-recommended practices. What should you do?
Answer options
- A. Use application generated sequential integer values as primary keys.
- B. Update default primary key values to max(primary_key) + 1.
- C. Use a UUID function that generates UUID Version 4 values as primary keys.
- D. Generate values by using BIT_REVERSED_POSITIVE sequences.
Correct answer: D
Explanation
The correct answer is D because generating values with BIT_REVERSED_POSITIVE sequences ensures that the primary keys are unique and can be efficiently managed in Spanner. Option A suggests using application-generated integers, which could lead to conflicts, while B could result in duplicate keys if not carefully managed. Option C's use of UUIDs changes the key structure significantly, deviating from the integer-based keys originally in use.