GCP-CLOUD-ARCHITECT practice question 9 of 10

Your applications will be writing their logs to BigQuery for analysis. Each application should have its own table. Any logs older than 45 days should be removed. You want to optimize storage and follow Google recommended practices. What should you do?

Full set: 333 questions

Domain Analyzing and optimizing technical and business processes

Answer options
A: Configure the expiration time for your tables at 45 days
B: Make the tables time-partitioned, and configure the partition expiration at 45 days Correct answer
C: Rely on BigQuery’s default behavior to prune application logs older than 45 days
D: Create a script that uses the BigQuery command line tool (bq) to remove records older than 45 days
Correct Answer:
B. Make the tables time-partitioned, and configure the partition expiration at 45 days
Explanation

Using time-partitioned tables is the Google-recommended best practice for managing time-series data like logs. By partitioning the table by day and setting the partition expiration to 45 days, BigQuery will automatically and efficiently delete partitions older than the specified limit. This approach optimizes storage costs and query performance because it avoids costly Data Manipulation Language (DML) operations that would require scanning the table to delete old rows. It is a more manageable and cost-effective solution than manual scripting or whole-table expiration.

Why Incorrect

A. Configuring table expiration would delete the entire table after 45 days, not just the old records, resulting in complete data loss.
C. BigQuery does not have a default behavior to automatically prune data; data retention must be explicitly configured by the user.
D. Using a script with DML statements (DELETE) to remove old records is expensive, as it requires a full table scan and incurs query costs.

References

1. Google Cloud Documentation, "Introduction to partitioned tables," Section: "Partition expiration." It states, "Setting a partition expiration is a cost-effective way to manage storage."

2. Google Cloud Documentation, "Managing partitioned tables," Section: "Updating a partition expiration time." This guide provides instructions on how to set partitionexpirationdays.

3. Google Cloud Documentation, "BigQuery best practices: cost control," Section: "Use table expiration or partitioned tables to prune old data." This section explicitly recommends partition expiration over DML for deleting old data.

Scroll to Top