Amazon Athena

Why Athena?

Amazon Athena is a serverless, interactive analytics service built on open-source frameworks that lets you analyze petabytes of data where it lives. With Athena, you can run SQL queries and analyze data interactively in notebooks, using the engine you choose for the work. SQL queries run on the DuckDB engine, now available in preview, or on Athena engine version 3 (based on Trino). Interactive analysis in notebooks runs on Apache Spark. There is no infrastructure to set up or manage. Pricing is simple. You pay based on the compute you use or the data your queries scan.

Athena includes a default workgroup, so you can run your first query right away. Add workgroups to separate teams and workloads, set data usage limits, and track costs.

The engine you choose for your workgroup sets how you are charged.

  • Run SQL queries with the DuckDB engine, available in preview, and pay for the compute each query uses, billed per millisecond with a 100 millisecond minimum.
  • Run SQL queries with Athena engine version 3 and pay for the data each query scans or for Capacity Reservations.
  • Run Apache Spark Python code and pay an hourly rate for running your code.

      

AWS pricing calculator

Calculate your Amazon Athena and architecture cost in a single estimate.

Create your custom estimate now

      

SQL queries with the DuckDB engine (Preview)

SQL queries with per TB scanned pricing

With per TB scanned pricing, you can get started quickly and pay only for the data scanned by queries you run. Per TB scanned pricing is available only with Athena engine version 3. You are charged for the number of bytes scanned per query, rounded up to the nearest megabyte, with a 10 MB minimum per query. There are no charges for Data Definition Language (DDL) statements like CREATE, ALTER, or DROP TABLE statements for managing partitions, or failed queries. Canceled queries are billed for the total amount of data scanned when the query is canceled.

You can save up to 90% per query and get better performance by compressing, partitioning, and converting your data into columnar formats. Compressing your data allows Athena to process less data, and partitioning allows Athena to process only the data necessary for your query. This leads to cost savings and improved performance. Converting your data to columnar formats allows Athena to selectively read only required columns to process the data.

SQL queries with Capacity Reservations

Use Capacity Reservations when you want dedicated compute resources for your SQL queries or prefer a flat-rate, hourly pricing structure. Capacity Reservations are available only with Athena engine version 3. With Capacity Reservations, you request Data Processing Units (DPU), which represent the resources necessary to run queries, and assign them to your workloads. One DPU typically provides 4 vCPU and 16 GB of memory. You pay only for the capacity you need and the duration it is active in your account, with a 1 minute minimum, from the time the capacity is requested until you cancel it and any running queries finish. There are no charges for data scanned. You can start with as few as 4 DPU and add or remove capacity in increments of 4 DPU as your needs change. Capacity is held for you as long as you need it, and can be canceled at any time.

For added flexibility, you can use Capacity Reservations and per TB scanned pricing in the same account and to meet different performance, workload isolation, and cost goals.

Apache Spark

Additional costs

Athena queries data directly from Amazon S3. There are no additional storage charges for querying your data with Athena. You are charged standard S3 rates for storage, requests, and data transfer. Query results that you store in an S3 bucket of your choice are billed at standard S3 rates.

  • You are billed by S3 when your workloads read, store, and transfer data. This includes successful and unsuccessful queries. SQL query results and Spark calculation results that you store in an S3 bucket of your choice are billed at standard S3 rates.. See Amazon S3 pricing for more information.
  • If you use the AWS Glue Data Catalog with Athena, you are charged standard Data Catalog rates. For details, visit the AWS Glue pricing page.
  • SQL queries on federated data sources (data not stored on S3) are billed per terabyte (TB) scanned by Athena aggregated across data sources, rounded up to the nearest megabyte with a 10 megabyte minimum per query, unless Capacity Reservations are used. Such queries also invoke AWS Lambda functions in your account, and you are charged for Lambda use at standard rates. Lambda functions invoked by federated queries are subject to Lambda’s free tier. Visit the Lambda pricing page for details. Federated queries are available only with Athena engine version 3.

Pricing examples

Example 1 – SQL queries with the DuckDB engine

Consider a dashboard that runs a query to summarize a year of sales data stored as Apache Parquet files on Amazon S3. Athena runs the query on 4 DPU and spends 2 seconds (2,000 milliseconds) processing your data.

  • Billed DPU-hours = 4 DPU × 2,000 milliseconds ÷ 3,600,000 milliseconds per hour = 0.0022222 DPU-hours
  • This query would cost $0.0007778 (0.0022222 DPU-hours × $0.35 per DPU-hour). Running this query 1,000 times a month would cost $0.78.

The same dashboard runs a lookup query on a small table. Athena runs the query on 0.25 DPU and spends 1 second (1,000 milliseconds) processing your data.

  • Billed DPU-hours = 0.25 DPU × 1,000 milliseconds ÷ 3,600,000 milliseconds per hour = 0.0000694 DPU-hours
  • This query would cost $0.0000243 (0.0000694 DPU-hours × $0.35 per DPU-hour). Running this query 1,000,000 times a month would cost $24.30.

Example 2 – SQL query with per TB scanned pricing

Consider a table with 4 equally sized columns, stored as an uncompressed text file with a total size of 3 TB on Amazon S3. Running a query to get data from a single column of the table requires Amazon Athena to scan the entire file because text formats can’t be split.

  • This query would cost: $15. (Price for 3 TB scanned is 3 * $5/TB = $15.)

If you compress your file using GZIP, you might see 3:1 compression gains. In this case, you would have a compressed file with a size of 1 TB. The same query on this file would cost $5. Athena has to scan the entire file again, but because it’s three times smaller in size, you pay one-third of what you did before. If you compress your file and also convert it to a columnar format like Apache Parquet, achieving 3:1 compression, you would still end up with 1 TB of data on S3. But, in this case, because Parquet is columnar, Athena can read only the column that is relevant for the query being run. Because the query in question only references a single column, Athena reads only that column and can avoid reading three-fourths of the file. Since Athena only reads one-fourth of the file, it scans just 0.25TB of data from S3.

  • This query would cost: $1.25. There is a 3x savings from compression and 4x savings for reading only one column. 
    (File size = 3TB/3 = 1 TB. Data scanned when reading a single column = 1TB/4 = 0.25 TB. Price for 0.25 TB = 0.25 * $5/TB = $1.25)

Example 3 – SQL queries with Capacity Reservations

Suppose your team supports a business intelligence application that provides self-service analytics to users during business hours. You analyze your query patterns and find your application is busiest during the first 15 minutes of each hour, where you support a peak of 20 concurrent queries, and each query requires at most 8 DPU. You create a Capacity Reservation with 160 DPU (20 queries × 8 DPU per query) to handle your peak concurrency. 

  • The cost to support your peak workload with Capacity Reservations is calculated as: 160 DPU × $0.30 per DPU hour × 0.25 hours = $12.00 USD.

During the off-peak 45 minutes of each hour when query volume drops, you reduce capacity to 16 DPU to serve up to 4 queries at a time.

  • The cost to support your workload with Capacity Reservations during the off-peak time is: 16 DPU × $0.30 per DPU hour × 0.75 hours = $3.60 USD.
  • The total cost to support your workload for one hour is: $12.00 USD + $3.60 USD = $15.60 USD.

Example 4 – Apache Spark application

Consider using a notebook in the Athena console for pulling sales figures for the previous quarter and graphing them to create a report. You start a session using a notebook. Your session lasts for 1 hour and submits 6 calculations as part of the session. Each calculation takes 20 1-DPU worker nodes to run and lasts for 1 minute.

  • Worker DPU-hours = Number of calculations * DPUs used per calculations * execution time of calculation = 6 calculations * 20 DPUs per calculation * (1/60) hours per calculation = 2.0 DPU-hours
  • Driver DPU-hours = DPUs used per session * session time = 1 DPUs per session * 1 hours per session = 1.0 DPU-hours
  • Total DPU-hours = Worker DPU-hours + Driver DPU-hours = 2.0 DPU-hours + 1.0 DPU-hours = 3.0 DPU-hours
  • Spark application charges = $0.35 per DPU-hour * 3.0 DPU-hours = $1.05

Note: S3 will charge you separately to store and read your data and the results of your execution.

Additional pricing resources

AWS Pricing Calculator

Easily calculate your monthly costs with AWS

Get pricing assistance

Contact AWS specialists to get a personalized quote

Product-Page_Standard-Icons_01_Product-Features_SqInk
Visit the getting started page

Learn how to get started with Amazon Athena.

Learn more »
Product-Page_Standard-Icons_03_Start-Building_SqInk
Start building in the console

Get started building with Amazon Athena in the AWS Management Console.

Sign in »
Next-Steps-Icon_Experts
Contact an expert

Explore the Amazon Athena support options.

Contact us »