1. A healthcare provider is designing a schema for BigQuery to store de-identified patient lab results. Each lab result has: patient_id (hashed), test_name, result_value, result_date, and lab_location. Queries will frequently filter by test_name and result_date (across millions of rows), and occasionally join with a demographics table on patient_id. How should you design the table schema and partitioning strategy?
- A. Partition by result_date; cluster by test_name and patient_id✓ Correct
- B. Partition by patient_id; cluster by result_date and test_name
- C. Partition by test_name; cluster by result_date
- D. Use no partitioning; apply clustering on all three columns
Explanation
Option A is correct. Partitioning by result_date aligns with the most common filter pattern (queries filtering by date range, e.g., "results from the last 30 days"). Clustering by test_name and patient_id optimizes the secondary filter and join patterns. Partitioning reduces the data scanned for date-range queries (mandatory pruning), while clustering provides optional pruning for test_name. BigQuery charges by data scanned, so this strategy minimizes cost. Option B (partition by patient_id) is inefficient—patient_id has high cardinality (~millions of unique values), creating too many partitions and fragmenting data, which hurts query performance and increases metadata overhead. Option C (partition by test_name) creates too few partitions; test_name has low cardinality and doesn't reflect access patterns. Option D (no partitioning) scans the entire table for every query, increasing cost and latency—partitioning is essential for billion-row tables.