Topic 1 Question 140
You need to create a new transaction table in Cloud Spanner that stores product sales data. You are deciding what to use as a primary key. From a performance perspective, which strategy should you choose?
The current epoch time
A concatenation of the product name and the current epoch time
A random universally unique identifier number (version 4 UUID)
The original order identification number from the sales system, which is a monotonically increasing integer
解説
Reference: https://www.uuidgenerator.net/version4

ユーザの投票
コメント(7)
- 正解だと思う選択肢: C
According to the documentation: Use a Universally Unique Identifier (UUID) You can use a Universally Unique Identifier (UUID) as defined by RFC 4122 as the primary key. Version 4 UUID is recommended, because it uses random values in the bit sequence. Version 1 UUID stores the timestamp in the high order bits and is not recommended.
👍 6Remi20212022/09/13 - 正解だと思う選択肢: B
Answer should be B as in all the other options hotspotting is possible. According to proper schema design guideline.. Schema design best practice #1: Do not choose a column whose value monotonically increases or decreases as the first key part for a high write rate table.
Supporting link: https://cloud.google.com/spanner/docs/schema-design#primary-key-prevent-hotspots
👍 2jsree2362022/09/05 - 正解だと思う選択肢: C
A and D are not valid, because they monotonically increase. C avoid hotspots for sure, but It's nor relate with querys. So for writing performance it's perfect that the reason for chose this: “You need to create a new transaction table in Cloud Spanner that stores product sales data”. They only ask you to store product data, its a writing ops. If the question had spoken about query the info or hard performance read, the best option would be B, because it has the balance of writing/reading best practices. There are a few disadvantages to using a UUID:
They are slightly large, using 16 bytes or more. Other options for primary keys don't use this much storage. They carry no information about the record. For example, a primary key of SingerId and AlbumId has an inherent meaning, while a UUID does not. You lose locality between records that are related, which is why using a UUID eliminates hotspots.https://cloud.google.com/spanner/docs/schema-design#uuid_primary_key
👍 2odacir2022/12/08
シャッフルモード