# Amazon Athena

> Run SQL directly on files sitting in S3, with no database to set up.

- Level: Intermediate
- Topics: AWS, Data
- URL: https://tidbit.legios.com.ar/amazon-athena/
- In Spanish: [Amazon Athena](https://tidbit.legios.com.ar/es/amazon-athena/)

**Amazon Athena** is a query service: you point it at files stored in Amazon S3 (CSV, JSON, Parquet, logs), describe their columns once, and run standard SQL against them. There is no server to start and no data to load: Athena reads the files when you run the query, and you pay per amount of data scanned (roughly 5 dollars per terabyte).

It exists because a lot of valuable data lives as files, not inside a database: application logs, exports from other systems, clickstreams, sensor readings. Loading all of that into a data warehouse is slow and costly; with Athena you query it where it is. It is the query engine of the data lake pattern: S3 as the storage, the AWS Glue Data Catalog as the list of tables and columns, Athena as the SQL layer.

Example: a company keeps a year of web server logs in S3, in one folder per day. An analyst runs `SELECT status, COUNT(*) FROM logs WHERE day = '2026-10-01' GROUP BY status` and gets the answer in seconds, scanning only that day's folder. Converting the logs to Parquet, a compressed column-oriented format, makes the same query scan far less data and cost far less.

Athena is built on Trino (formerly Presto) and can also run Apache Spark. It shines for ad hoc analysis and scheduled reports; for a team hitting the same tables all day and expecting sub-second answers, a warehouse like Amazon Redshift is the better fit.

## An analogy

A librarian who answers questions by reading the boxes in the archive directly, instead of first copying every document into a filing system. Slower per question than a filing system, but it works on day one and you pay only for what gets read.

## Keep in mind

- Serverless SQL over files in S3: no cluster to run, no loading step.
- Billed per data scanned, so columnar formats like Parquet and folder partitions cut costs a lot.
- Table definitions live in the Glue Data Catalog and are shared with other AWS tools.
- Great for ad hoc analysis and logs; a warehouse suits heavy, constant workloads.

## Go deeper

- [What is Amazon Athena? (official docs)](https://docs.aws.amazon.com/athena/latest/ug/what-is.html)
- [Amazon Athena product page](https://aws.amazon.com/athena/)

## Related terms

- [Amazon S3](https://tidbit.legios.com.ar/amazon-s3/): A giant online drawer for files, rented by the gigabyte.
- [CSV](https://tidbit.legios.com.ar/csv/): A plain text file that holds a table: one row per line, commas between values.
- [JSON](https://tidbit.legios.com.ar/json/): The plain-text format programs use to hand each other structured data.
- [Parquet](https://tidbit.legios.com.ar/parquet/): A file format that stores tables by column, compressed, so analytics reads far less.
- [SQL](https://tidbit.legios.com.ar/sql/): The language you use to ask a database questions.
- [Server](https://tidbit.legios.com.ar/server/): A computer whose job is to answer requests from other computers, all day, every day.
- [Database](https://tidbit.legios.com.ar/database/): An organized store of data that programs can search and update safely.
- [Data warehouse](https://tidbit.legios.com.ar/data-warehouse/): A database built for analysis: years of history, from many sources, in one place.
