SysPadLessons › analytics lessons › Amazon Athena

How Amazon Athena works

Serverless SQL queries directly over data in S3. Billed per terabyte scanned - partitioning and columnar formats (Parquet) cut both cost and latency. Throughput is bounded by the concurrent-query quota.

You have gigabytes of logs sitting in S3 and one question to answer. Spinning up a database and loading it all in would take longer than the answer is worth. Athena lets you run SQL straight against those files, no servers, no loading, and you pay only for the bytes the query reads.

What you will learn

SQL on files, no servers

Athena is serverless interactive query: you define a table that points at files in S3, then run standard SQL (it runs the Trino/Presto engine). There is nothing to provision, and the data stays in S3, you query it in place.

Schema-on-read via the Glue catalog

Athena uses schema-on-read: you describe the columns when you query, the files are never reformatted. Those table definitions live in the Glue Data Catalog, the same catalog Redshift Spectrum and EMR can share, so one schema serves many engines.

Ad-hoc log analysis, querying CloudTrail/VPC flow logs, one-off data investigations, and BI dashboards over a data lake.

You pay per terabyte scanned

The pricing model is the whole game: about $5 per TB of data scanned. A query that reads less data costs less and runs faster. So the same logical query can be a few cents or many dollars depending entirely on how the data is laid out.

Columnar + partitioning = cheap and fast

Two moves cut scanned bytes dramatically. Store data in a columnar format like Parquet or ORC so a query reads only the columns it selects, and partition by common filters (like date) so it reads only the relevant folders. Compression helps further.

Flashcards

What makes Athena different from a regular SQL database?
It is serverless and queries files in place in S3: no servers to run and no loading step.
Where do Athena table definitions live, and what is schema-on-read?
In the Glue Data Catalog. Schema-on-read means the schema is applied at query time; the underlying files are never reformatted.
How is Athena priced?
About $5 per TB scanned. Reading less data is both cheaper and faster, so data layout decides the bill.
Two layout changes that cut Athena scan cost the most?
Columnar format (Parquet/ORC) so only selected columns are read, and partitioning so only relevant folders are read.
When is Athena the wrong tool?
For low-latency, high-concurrency per-request lookups. It is for ad-hoc and analytical queries, not an app's hot path.

Sources

Open the SysPad canvas · Official Amazon Athena documentation

Other analytics lessons