Database / Google Spanner Database Interview questions
Describe primary keys in Google Spanner schema design?
Every Spanner table requires a primary key, and unlike most relational databases, that key also decides how rows are physically distributed across storage splits. Rows are stored in primary-key order, so the key you choose directly controls which machine handles which rows.
This makes primary key choice a performance decision, not just a uniqueness rule. A key that increases monotonically, like an auto-incrementing integer or a timestamp, sends all new writes to the same split, creating a hotspot. Common fixes include prefixing the key with a hashed or shuffled value, using a UUID, or bit-reversing a sequential ID so consecutive values land on different splits. Composite keys are also used to support interleaved parent-child relationships.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
