Athena queries and partition pruning
Query selected data
Athena SQL queries data in S3 using catalog metadata and supported table formats. The example uses a string date partition and selects only cents for one day. In the local SQLite fixture the same basic aggregate returns 3500 cents from two fictional rows. SQLite is a local relational engine; its result validates the arithmetic only, not Athena dialect, distributed execution or scan performance.
SELECT SUM(cents) FROM sales WHERE sale_date = '2026-01-01';Partition pruning and column selection
Assume three date partitions each contain 10 GB of data. A full scan is modeled as 30 GB; selecting one date with an equality predicate is modeled as 10 GB before column pruning. With Parquet, reading only required columns can reduce bytes further, but the ratio depends on compression, statistics, data types and layout. Avoid SELECT * for reports, use compatible predicates on partition keys, and inspect actual query statistics. LIMIT alone is not a reliable scan cap.
Model the cost instead of promising savings
At a hypothetical 5 currency units per decimal TB scanned, 30 GB costs 0.15 units and 10 GB costs 0.05 units, ignoring billing minima and rounding. This is not a current AWS price quote. Also budget S3 storage and requests, Glue ETL compute, catalog metadata and requests, result storage, KMS and applicable transfer. Other Athena capacity and workload pricing models differ. Set workgroup scan controls and review regional pricing before optional cloud tests.
Diagnose an empty or expensive result
An empty date report may mean no orders, unregistered partitions, wrong paths or a schema mismatch. Check known source counts, catalog location and partitions before changing SQL. If cost rises, compare scan bytes, partition predicate and file sizes; do not conclude that local SQLite timings predict AWS behavior. Run the synthetic lab, compare all-date and one-date totals, then explain the difference between row totals and modeled scan bytes.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Athena queries and partition pruning — knowledge check
Reason about data layout, governance and query costs.
Which predicate can prune date partitions?
What is modeled scan volume for one of three 10 GB partitions?
At hypothetical 5 units/TB what costs 10 GB?
What does a SQLite test demonstrate?
What should be checked for an unexpectedly empty report?