An e-commerce company uses Cloud Spanner for order processing. They need to query orders by customer ID and retrieve all order items. Which schema design pattern should they use for optimal performance?
Interleaving co-locates child rows with their parent, enabling efficient joins and strong consistency.
Why this answer
Interleaved tables in Cloud Spanner physically co-locate parent and child rows on the same split, so querying orders by customer_id and retrieving all order items becomes a single, fast key-range scan without cross-node joins. This design exploits Spanner's hierarchical storage model to minimize latency and maximize throughput for this access pattern.
Exam trap
Cisco often tests the misconception that secondary indexes alone are sufficient for performance, ignoring that Spanner's distributed architecture makes cross-table joins expensive, whereas interleaving provides physical co-location that avoids network round-trips.
How to eliminate wrong answers
Option B is wrong because a single table with nullable columns violates normalization, wastes storage, and forces complex queries to filter order-item rows from order rows, eliminating Spanner's interleaving performance benefit. Option C is wrong because storing order items as a repeated field (e.g., ARRAY<STRUCT>) prevents independent indexing and filtering of individual items, and updating a single item requires rewriting the entire order row, causing contention and poor concurrency. Option D is wrong because two separate tables with secondary indexes on customer_id and order_id require a distributed join across splits, incurring cross-node communication and higher latency compared to the co-located access of interleaved tables.