Question 121 · 340 in bank
You are collecting IoT sensor data from millions of devices across the world and storing the data in BigQuery. Your access pattern is based on recent data, filtered by location_id and device_version with the following query:
You want to optimize your queries for cost and performance. How should you structure your data?
Show answer
Answer: B
Explanation
1. Partitioning the data by create_date will allow BigQuery to prune partitions that are not relevant to the query by date. 2. Clustering the data by location_id and device_version within each partition will keep related data close together and optimize the performance of filters on those columns. This provides both the pruning benefits of partitioning and locality benefits of clustering for filters on multiple columns. The query provided indicates that the access pattern is primarily based on the most recent data (within the last 7 days), filtered by location_id and device_version. Given this pattern, you would want to optimize your table structure in such a way that queries scanning through the data will process the least amount of data possible to reduce costs and improve performance.
Source: Adapted from community discussion — MaxNRG