An e-commerce company uses Amazon Kinesis Data Firehose to deliver clickstream data to an Amazon S3 bucket. The data is then queried using Amazon Athena. The marketing team wants to run daily reports that aggregate click events by product ID. However, the reports are slow because Athena scans the entire dataset each time. The data is partitioned by date (e.g., s3://bucket/clickstream/2023/01/01/). The product ID is a column within the data. The data engineering team wants to improve query performance without moving the data to another service. Which approach should the team take?
Partitioning by product ID allows Athena to skip irrelevant partitions.
Why this answer
Repartition the data by product ID in addition to date. This adds a partition level for product ID, so queries that filter on product ID will only scan the relevant partitions. Option A (convert to Parquet) reduces data scanned due to columnar storage and compression, but without partition pruning on product ID, Athena would still scan all partitions for each query.
Option B (Redshift Spectrum) would still require scanning data, and involves additional service complexity. Option C (create a view) does not change physical storage; it only provides a logical filter, but Athena still scans all underlying data. Therefore, repartitioning by product ID provides the most direct improvement for queries filtering by product ID.