Data sitting in S3 is only useful if you can question it quickly, and Amazon Athena is the tool I reach for when I do not want to load anything anywhere first. It is serverless SQL over your own buckets, which is wonderful right up until a careless query scans terabytes and you get the bill for it. These six habits are how I keep Athena fast, cheap, and actually pleasant to use.
1. Store data in Parquet, partitioned by how you query it. Athena charges for the bytes it scans, so the file format matters more than almost anything else. Convert raw CSV or JSON into Parquet or ORC, and partition by a column you genuinely filter on, like date or region. I have seen the same query drop from scanning gigabytes to scanning megabytes just from this one change, because Athena skips every partition your WHERE clause rules out.
2. Select only the columns you need. SELECT * is the most expensive habit in Athena. Columnar formats let Athena read just the columns you name, so listing three columns instead of thirty can cut the scan dramatically. Before I run anything exploratory, I pause and delete the columns I will not actually look at.
3. Put the partition filter in every query. Partitioning only saves money if your WHERE clause uses it. A query with no date filter scans every partition, which defeats the whole setup. I treat a missing partition filter the way I treat a missing WHERE on a DELETE: a sign to stop and fix the query first.
4. Keep files reasonably sized and compressed. Thousands of tiny files make Athena work harder, and one giant uncompressed file makes it scan more than it must. Aim for files in the tens to low hundreds of megabytes, compressed with Snappy or ZSTD, and use CTAS or INSERT INTO to compact small files left behind by streaming pipelines.
5. Set guardrails with workgroups. Every team member does not need an unlimited query budget. I put day-to-day querying in a workgroup with a per-query scanned-bytes limit and CloudWatch alarms on total scanned data, so one runaway query fails fast instead of running up a bill. It also makes it easy to see who is scanning what.
6. Save and reuse the queries that matter. Ad-hoc does not have to mean throwaway. When a query proves useful, save it, parameterize the date range, and for anything run repeatedly, turn it into a CTAS table so the next run reads the small result instead of re-scanning the raw data. My saved-query list is basically a runbook for how our data behaves.
Key takeaways: partition by what you filter on, store columnar and compressed data, never SELECT *, always include the partition filter, cap scans with workgroup limits, and promote repeated queries into saved queries or CTAS tables. Athena rewards a little discipline up front with queries that stay fast and bills that stay boring, which is exactly what ad-hoc analysis should feel like.
Loading article