Optimising Pipeline Cost and Performance
This lesson explains the handful of techniques that improve both the cost and the speed of data pipelines, which spend most of their money on data scanned, compute provisioned and data stored.
Learning outcomes
After completing this lesson, you will be able to:
- Reduce data scanned with columnar formats, compression and partitioning.
- Pay for less compute with right-sizing and incremental processing.
- Reduce storage cost with lifecycle rules and compaction.
- Track spending with tags and Cost Explorer.
Scan less data
Athena and Redshift Spectrum charge by the data scanned, so reading less data makes queries both cheaper and faster. Converting CSV and JSON to Parquet or ORC lets queries read only the columns they need, often scanning 80–90% less. Partitioning by the most common filter, usually date, lets queries skip whole partitions, and partition projection avoids slow partition listing when there are very many.
Compacting many small files into files of about 128 MB to 1 GB reduces the overhead of opening each one and improves parallelism. Compression with Snappy or ZSTD reduces storage and I/O. Materialised views and query result reuse avoid recomputing the same aggregation for each user. The following table summarises the techniques.
| Technique | Effect |
|---|---|
| Convert CSV and JSON to Parquet or ORC | Columnar reads; often 80–90% less data scanned |
| Partition by the most common filter (usually date) | Queries skip whole partitions |
| Partition projection in Athena | Avoids slow partition listing with many partitions |
| Compact small files to 128 MB–1 GB | Fewer requests and better parallelism |
| Compress with Snappy or ZSTD | Less storage and I/O |
| Materialised views and result reuse | Avoid recomputing the same aggregation |
The following diagram shows how much data the same Athena query scans after each of several optimisations.

Scanning less
Pay for less compute
Compute costs fall when capacity matches the work and nothing is processed twice. In AWS Glue, auto scaling removes idle workers during a run, Flex execution runs non-urgent jobs on spare capacity at a lower price, and job bookmarks ensure each run processes only new data. In Amazon EMR, Spot Instances for task nodes, transient clusters that terminate after their jobs, and EMR Serverless all avoid paying for idle or full-price capacity.
For Amazon Redshift, Redshift Serverless suits intermittent workloads, and provisioned clusters can be paused when idle or resized to fit. For unpredictable traffic, on-demand capacity mode in Kinesis Data Streams and DynamoDB avoids paying for capacity provisioned for peaks. The following table summarises the techniques.
| Technique | Applies to |
|---|---|
| Glue auto scaling and Flex execution for non-urgent jobs | AWS Glue |
| Spot Instances for task nodes; transient clusters; EMR Serverless | Amazon EMR |
| Redshift Serverless for intermittent workloads; pause and resize provisioned clusters | Amazon Redshift |
| Job bookmarks to process only new data | AWS Glue |
| On-demand capacity mode for unpredictable streams | Kinesis Data Streams, DynamoDB |
Which saving applies?
Store less, for less
Storage costs grow steadily in a data lake unless they are managed. S3 lifecycle rules move raw data to S3 Standard-IA or Glacier storage classes once it has been processed, because it is read rarely afterwards. For data whose access pattern is unknown or changes, S3 Intelligent-Tiering moves objects between tiers automatically based on actual access, without retrieval fees.
Table formats and streams accumulate hidden storage too. Iceberg snapshot expiry and orphan file removal stop old table versions from accumulating indefinitely, and Kinesis retention should be set to the replay window the pipeline actually needs and no longer, because extended retention is charged.
Track and control spending
Optimisation needs visibility of where the money goes. AWS Cost Explorer shows spending over time by service, account and cost allocation tag, so tagging every pipeline resource with its project and environment reveals which pipeline, job or team drives cost; it also forecasts spending and recommends Savings Plans. AWS Budgets alerts by email or SNS when actual or forecast spending passes a threshold, for example a monthly budget for the analytics account, and budget actions can apply a restrictive policy automatically. Athena workgroup data limits add a per-query or per-workgroup control. The following table summarises the tools.
| Tool | Use for |
|---|---|
| AWS Cost Explorer | Analysing and forecasting spend by service, account or tag |
| AWS Budgets | Alerts and actions when actual or forecast spend passes a threshold |
| Cost allocation tags | Attributing cost to pipelines, teams and environments |
| Athena workgroup data limits | Stopping or alerting on queries that scan too much data |
Cost tools
Cutting an Athena bill
A team's Athena bill is $6,000 a month. Queries filter on event_date and read five of 60 columns from gzipped JSON stored as thousands of 1 MB files.
-- Before: every query scans the whole table (~1.2 TB)
SELECT user_id, COUNT(*) FROM events_json WHERE event_date = '2026-10-08' GROUP BY user_id;
-- After: Parquet, partitioned by event_date, files compacted to ~256 MB
SELECT user_id, COUNT(*) FROM events WHERE event_date = '2026-10-08' GROUP BY user_id;
-- Scans one partition, five columns: ~2 GBPartitioning removes about 99% of the data by date, Parquet removes most of the remaining columns, and compaction removes per-file overhead. The bill falls to well under $100 a month and queries run in seconds instead of minutes.
Which features make a pipeline process only data that changed?
Show answer
Glue job bookmarks for files, and change data capture for databases.
Exam Tips
Remember for the exam
- Parquet + partitioning + compaction is the standard answer to slow or expensive queries.
- Spot task nodes, Glue Flex and Redshift Serverless reduce compute cost.
- Job bookmarks and CDC process only what changed.
- Lifecycle rules and Iceberg snapshot expiry control storage cost.
- Alert when pipeline spending is forecast to exceed a threshold: AWS Budgets; analyse spend by tag: Cost Explorer.