nerdexam
Google

PROFESSIONAL-CLOUD-DATABASE-ENGINEER · Question #165

You are migrating an on-premises database to Spanner. There are a few tables, each with a few hundred records that do not have a primary key on the source database. You need to migrate all of the…

The correct answer is B. Use the GENERATE_UUID() function to generate universally unique identifier (UUID) values with. Using GENERATE_UUID() to create UUID primary keys is the correct approach. Cloud Spanner requires every table to have a primary key, so tables without one must have keys assigned during migration. UUID values are randomly distributed across the UUID space, meaning writes are…

Migrating data to a Google Cloud database

Question

You are migrating an on-premises database to Spanner. There are a few tables, each with a few hundred records that do not have a primary key on the source database. You need to migrate all of the tables over to the news database while avoiding hot-spotting issues. What should you do-

Options

  • ALoad the data into Spanner, and designate a primary key later based on business need.
  • BUse the GENERATE_UUID() function to generate universally unique identifier (UUID) values with
  • CDuring the migration, swap the order of keys so that the column that contains the monotonically
  • DMigrate the tables with no primary key to maintain consistency with source.

How the community answered

(28 responses)
  • A
    4% (1)
  • B
    79% (22)
  • C
    4% (1)
  • D
    14% (4)

Explanation

Using GENERATE_UUID() to create UUID primary keys is the correct approach. Cloud Spanner requires every table to have a primary key, so tables without one must have keys assigned during migration. UUID values are randomly distributed across the UUID space, meaning writes are spread evenly across Spanner's split boundaries rather than concentrating on a single server - this directly prevents hot-spotting. Loading data first and designating a PK later (A) is not possible in Spanner; the primary key must be defined at table creation time and cannot be added afterward without recreating the table. Swapping the order of keys (C) can help when dealing with monotonically increasing keys (e.g., timestamps) by reversing byte order, but UUID generation is the cleaner and more direct solution when no natural key exists. Migrating tables with no primary key (D) is not supported by Spanner's schema model - every table must have a defined primary key.

Topics

#Spanner Primary Keys#Hot-spotting#Data Migration#UUID

Community Discussion

No community discussion yet for this question.

Full PROFESSIONAL-CLOUD-DATABASE-ENGINEER Practice