PROFESSIONAL-CLOUD-DATABASE-ENGINEER · Question #187
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
The correct answer is D. Generate values by using BIT_REVERSED_POSITIVE sequences.. Using Spanner’s BIT_REVERSED_POSITIVE sequence function lets you keep your existing integer‐typed keys while automatically scattering new key values across Spanner’s key space, avoiding hotspotting. This approach requires minimal application changes (you still use integers) and f
Question
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-
Options
- AUse application generated sequential integer values as primary keys.
- BUpdate default primary key values to max(primary_key) + 1.
- CUse a UUID function that generates UUID Version 4 values as primary keys.
- DGenerate values by using BIT_REVERSED_POSITIVE sequences.
How the community answered
(28 responses)- A4% (1)
- B18% (5)
- C7% (2)
- D71% (20)
Explanation
Using Spanner’s BIT_REVERSED_POSITIVE sequence function lets you keep your existing integer‐typed keys while automatically scattering new key values across Spanner’s key space, avoiding hotspotting. This approach requires minimal application changes (you still use integers) and follows Google’s guidance for distributed primary keys in Spanner.
Topics
Community Discussion
No community discussion yet for this question.