Amazon Athena - Overview
Amazon Athena is the absolute king of ad-hoc SQL analytics when you need to query data sitting directly in Amazon S3 without the overhead of provisioning or managing a traditional database server! π
Because Athena is completely serverless, it integrates natively into data lakes, log aggregation pipelines, and business intelligence dashboards.
Key Takeawaysβ
Let's go over the core features, performance optimization techniques, and federated query patterns.
ποΈ Core Architecture & Pricing Modelβ
- Engine: Built on top of the open-source Presto / Trino SQL query engine.
- Supported Formats: Queries CSV, JSON, ORC, Avro, and Apache Parquet directly in S3.
- Pricing Mechanics ($5 / TB Scanned) π°: You are billed $5.00 per Terabyte of data scanned from S3 (with a 10 MB minimum per query). DDL statements (
CREATE,ALTER,DROP) are 100% free! - Serverless & In-Place: Data remains in your S3 bucketsβAthena brings the compute to the data.

β‘ Athena Performance Optimization (The Exam Goldmine)β
Because Athena pricing is tied directly to the volume of data scanned, optimizing performance translates directly into massive cost savings!
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β ATHENA PERFORMANCE OPTIMIZATION β
βββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββ
βΌ βΌ βΌ
π 1. COLUMNAR FORMATS π¦ 2. COMPRESSION π 3. PARTITIONING & FILE SIZES
β’ Use Apache Parquet or ORC β’ Compress files (Snappy, GZIP) β’ Partition S3 paths: `/year=2026/month=07/`
β’ Athena reads ONLY queried columns β’ Slashes data volume read over wire β’ Drastically reduces scanned S3 folders
β’ Converts via AWS Glue ETL jobs β’ Saves costs & speeds up execution β’ Consolidate small files into >128 MB blocks
- Use Columnar Data Formats (Parquet / ORC) π:
- Traditional row formats (CSV/JSON) force Athena to read the entire row even if you query just one column.
- Columnar formats allow Athena to selectively read only the specific columns requested in the
SELECTquery, cutting scanned data by up to 90%! (Convert CSV to Parquet using AWS Glue ETL).
- Compress Data Files π¦:
- Compress files using Snappy, GZIP, or ZSTD. Smaller file sizes = fewer bytes scanned from S3 = cheaper and faster queries.
- Partition Your Data Lakes π:
- Organize S3 bucket prefix paths into virtual partition keys:
s3://my-data-bucket/flight-data/year=2026/month=07/day=28/data.parquet - When running
SELECT * FROM flight_data WHERE year = '2026' AND month = '07', Athena skips 99% of the S3 bucket and scans only that specific subfolder!
- Organize S3 bucket prefix paths into virtual partition keys:
- Optimize File Sizes π:
- Avoid thousands of tiny KB-sized files. Consolidate data into larger file chunks (128 MB or larger) to reduce S3 request overhead and execution latency.
π Athena Federated Query (Beyond S3)β
Athena isn't locked down to S3! With Federated Queries, you can execute a single SQL query that joins datasets across multiple AWS and on-premises data sources in real time.
- How it Works: Uses AWS Lambda-based Data Source Connectors.
- Supported Targets: DynamoDB, ElastiCache (Redis), CloudWatch Logs, DocumentDB, RDS (MySQL/PostgreSQL), Redshift, and custom external databases.
- Example Use Case: Write one SQL statement to join active Redis session IDs with historical user profiles in DynamoDB and order history stored in S3 Parquet files!

Exam Tipsβ
- The S3 Log Analysis Rule π¨: If a question asks how to run ad-hoc SQL queries on S3 access logs, CloudTrail logs, or VPC Flow Logs without setting up a database or ETL clusterβchoose Amazon Athena.
- Cost Optimization Strategy: If a scenario states Athena queries are running too slowly or triggering massive S3 scan billsβselect converting raw JSON/CSV data into partitioned Apache Parquet files using AWS Glue!
- QuickSight Integration: Athena serves as the primary data abstraction layer for visualization in Amazon QuickSight.