Skip to main content

Welcome to a Grasp lesson

Create a free account to keep studying and create your own study path.

Lesson 76

Choosing the Right Data Store for Analytics

Recommended resources

Hello! Welcome back to our final module, Exam Preparation and Scenario Analysis.

In the last lesson, we focused on transforming raw data into a clean, structured format, leaving it optimized and ready for analysis in our S3 data lake. This sets the stage perfectly for today's topic, where we'll answer the crucial question: "Now that the data is ready, how should we query it?"

This lesson addresses the learning outcome: Select the appropriate storage and query service (e.g., Redshift, Athena, S3) based on query patterns, performance, and cost. Your experience with Athena and S3 gives you an excellent foundation here. We will build on that practical knowledge to create a formal decision-making framework, which is exactly what you'll need for the certification exam. We will compare the primary tools and learn to justify choosing one over the other based on specific scenario requirements.

The Spectrum of Querying in AWS

First, let's get a high-level view of the main services involved. The data pipeline you've been building in your mind—ingesting data, transforming it, and storing it in S3—culminates in this querying and analysis stage.

Top AWS Services A Data Engineer Should Know

This video from 'DataEng Uncomplicated' provides a concise overview of the key services for querying and analysis, putting S3, Redshift, and Athena into the context of a modern data architecture.

Please watch these three short segments to set the scene: S3 as a Data Lake (04:31 - 05:46): This reinforces the concept of S3 as the central storage for raw and processed data. AWS Redshift (06:33 - 07:10): Pay attention to its description as a data warehouse for analyzing terabytes/petabytes of data with complex, long-running queries. AWS Athena (07:20 - 07:58): Note its role for performing ad-hoc SQL queries directly on the data lake, its serverless nature, and its pay-per-scan cost model.

As the video shows, these services aren't competitors but rather different tools for different jobs. The key is understanding which job requires which tool.


A Deeper Dive into Each Service

To make the right choice, we need to understand the architecture, performance characteristics, and cost model of each service. The following article provides an excellent practical breakdown.

Choosing the Right AWS Data Service: A Practical Guide

This guide from a practitioner on Medium, titled 'Choosing the Right AWS Data Service', breaks down the real-world differences between Athena, Redshift, and their related features. We will use it as the foundation for our comparison.

First, please read the section 'Storage and Architecture'. It clearly outlines the fundamental difference between how Athena, Redshift, Redshift Spectrum, and S3 Select interact with your data in S3.

Let's dissect these services based on the article and other resources.

1. S3 and S3 Select: The Foundation and a Helper

You're already highly proficient with S3 as your data lake's storage layer. It holds your transformed data, often in columnar formats like Parquet or ORC for efficiency.

S3 Select is not a full-fledged query engine like Athena but a powerful optimization feature. It allows an application to retrieve a subset of data from an S3 object using simple SQL expressions.

  • Use Case: Imagine an ETL job or a Lambda function that only needs two columns out of a 50-column CSV file. Instead of downloading the entire large file and filtering it in memory, you can use S3 Select to pull only the required data. This reduces data transfer and processing time significantly.
  • Key Takeaway: Think of S3 Select as a filter at the storage layer, perfect for simple data extraction within a data pipeline, not for analytical queries.

2. Amazon Athena: The Serverless Data Lake Explorer

As you know from your experience, Athena allows you to run standard SQL queries directly on your S3 data.

  • Architecture: Serverless. There is no infrastructure to manage. It uses the AWS Glue Data Catalog for metadata.
  • Performance: Highly dependent on the underlying data's format and organization. Queries on partitioned, compressed, columnar (Parquet/ORC) data are dramatically faster and cheaper than on raw, unpartitioned CSVs. This is why the transformation step from the previous lesson is so critical.
  • Cost Model: Pay-per-query, based on the amount of data scanned (e.g., $5 per TB). This is ideal for unpredictable, ad-hoc, or infrequent query patterns.
  • Best For:
    • Exploratory data analysis and ad-hoc querying.
    • Data scientists who need flexible access to the data lake.
    • BI dashboards with low to moderate query frequency where you want to avoid managing a cluster.

3. Amazon Redshift: The High-Performance Data Warehouse

Redshift is a provisioned, petabyte-scale data warehouse designed for high-performance business intelligence (BI) and analytics.

  • Architecture: Cluster-based. You provision a cluster of nodes, and data must be loaded (using the COPY command) from S3 into Redshift's proprietary columnar storage format.
  • Performance: Delivers consistent, low-latency query performance for complex joins and aggregations, especially with high concurrency (many users querying at once). This performance is achieved because the data is optimized, indexed, and co-located on the cluster.
  • Cost Model: Pay-per-hour for the running cluster. This provides predictable costs for stable workloads. You can use Reserved Instances for significant savings on long-term commitments.
  • Best For:
    • Enterprise BI dashboards with high concurrency and strict performance SLAs.
    • Daily, weekly, or monthly reports with predictable, complex query patterns.
    • Workloads with many large, multi-table joins.

To understand the architecture and cost model of Redshift more deeply, which is a key differentiator, let's look at this next video.

Snowflake Vs. AWS RedShift Vs. GCP BigQuery Vs. Azure Synapse for Data Warehousing!

This segment from 'The Data Guy' channel provides an excellent deep dive into Redshift's architecture, pricing, and security model. It explains concepts like coupled storage/compute, RA3 nodes, and Redshift Spectrum.

Please watch from 05:07 to 08:58. Focus on: Architecture (05:07): How traditional Redshift nodes couple compute and storage, and how RA3 nodes change that. Redshift Spectrum (mentioned throughout): Understand its purpose—to query data in S3 from within Redshift. Pricing & Ecosystem (07:13): The difference between on-demand and reserved instances and its tight integration with AWS services. Security (08:21): The robust security features available.

Redshift Spectrum is a crucial feature that bridges the gap between the data warehouse and the data lake. It allows you to run SQL queries from your Redshift cluster that can join "hot" data stored locally in Redshift with "cold" or vast historical data stored in S3. You pay the Redshift cluster cost plus a per-scan charge for the S3 data, similar to Athena.


The Decision Framework: Making the Right Choice

Now let's bring it all together into a decision framework. An exam question will give you a scenario, and you'll need to weigh these factors to pick the best service.

This image provides an excellent side-by-side comparison of the key features.

Comparison of Amazon Redshift, Redshift Spectrum, and Athena
This table contrasts Amazon Redshift, Redshift Spectrum, and Amazon Athena across critical dimensions like use case, storage, optimization, and supported formats. It's a valuable reference for understanding their distinct roles.

To further sharpen our decision-making, let's review a set of practical guidelines and summary tables.

Choosing the Right AWS Data Service: A Practical Guide

We'll now return to the 'Choosing the Right AWS Data Service' guide and review the sections on performance, cost, and use cases. This will form the core of your decision framework.

Please read the following sections carefully: 'Performance in the Real World' and 'The Cost Reality': These sections give you a practical feel for how speed and cost play out. 'When to Use Each Service': This is the most critical section. Study the bullet points for Athena, Redshift, Redshift Spectrum, and S3 Select. This is exactly the logic you'll apply in the exam. 'Making the Decision': This provides a strategic approach for how an organization might evolve its data architecture, starting with one service and adding another as needs change.

Let's solidify this with one more resource that uses tables to compare specific technical features.

Amazon RedShift Spectrum vs Amazon Athena

The article 'Amazon RedShift Spectrum vs Amazon Athena' from Digital Cloud Training offers concise comparison tables that are great for quick review and memorization.

Quickly review the tables in this article. You don't need to read all the text, just focus on the tables comparing: Partitioning, Primary Keys, Data Formats, UDFs. Performance (Query Speed). Pricing. Then, read the final summary paragraphs that state when each service is best.

Test your understanding!

For each scenario, select the most appropriate service or feature (Athena, Redshift, Redshift Spectrum, or S3 Select) and justify your choice based on query patterns, performance, and cost.

Scenario A:
A financial services startup needs to analyze transaction logs stored in S3. The data science team needs to run complex, unpredictable queries to look for fraud patterns. They have a tight budget and want to avoid managing any infrastructure.

Scenario B:
A large retail company runs a series of standard, complex sales reports every morning. These reports are used to populate a BI dashboard accessed by 200 analysts across the company. Query performance must be fast (sub-minute) and consistent, even under high user load.

Scenario C:
A data processing application running on EC2 needs to check if a specific transaction_id exists within very large (5 GB) daily log files stored as compressed JSON in S3. The application needs to do this check thousands of times per hour and must be highly cost-effective and fast.

Scenario D:
The retail company from Scenario B has been using Redshift for 3 years. They now want to run a new quarterly report that joins the last 90 days of "hot" sales data (stored in their Redshift cluster) with 10 years of "cold" historical sales data archived in their S3 data lake. They do not want to significantly increase the size and cost of their Redshift cluster.

Show answer

Scenario A: Amazon Athena

  • Justification: The keywords are "unpredictable queries," "tight budget," and "avoid managing infrastructure." Athena's serverless nature and pay-per-query model are perfect for this. It allows the data science team to explore the data without the upfront cost or operational overhead of a provisioned Redshift cluster.

Scenario B: Amazon Redshift

  • Justification: The keywords are "standard, complex reports," "BI dashboard," "200 analysts" (high concurrency), and "fast and consistent" performance. This is the classic use case for a data warehouse. Redshift will provide superior and predictable performance for these structured, repetitive workloads compared to Athena. The hourly cost is justified by the strict performance and concurrency requirements.

Scenario C: S3 Select

  • Justification: The task is very specific: extracting a small piece of information from a large object for an application, not running broad analytical queries. Using S3 Select allows the application to retrieve only the data it needs, drastically reducing data transfer costs and processing time compared to downloading and parsing the entire 5 GB file for each check.

Scenario D: Redshift Spectrum

  • Justification: The company needs to query data both inside and outside its existing Redshift cluster ("hot" and "cold" data). Redshift Spectrum is designed for precisely this purpose. It allows them to extend their existing Redshift investment to query their S3 data lake without having to load all 10 years of historical data into the cluster, which would be prohibitively expensive.

Conclusion

You now have a clear framework for selecting the right storage and query service on AWS. By analyzing the requirements through the lenses of query patterns, performance needs, concurrency, and cost model, you can confidently navigate the scenarios presented in the Data Engineer - Associate exam.

Key Takeaways:

  • Amazon Athena: Your go-to for serverless, ad-hoc, exploratory queries on your S3 data lake. Cost is variable (pay-per-scan), and performance depends heavily on data organization.
  • Amazon Redshift: The choice for structured, high-performance, high-concurrency BI and reporting. Cost is predictable (pay-per-hour), and performance is consistently fast for queries on data loaded into the cluster.
  • S3 Select: A feature for applications to efficiently filter data within a single S3 object before transfer, reducing cost and latency for simple lookups.
  • Redshift Spectrum: A feature for Redshift users to query data that lives externally in their S3 data lake, enabling a hybrid data warehouse/data lake architecture.

Next Up:

We've now covered how to select the right tools for ingestion, transformation, and querying. But how do you connect all these steps into a reliable, automated, and observable workflow? In our next lesson, we will address the final piece of the puzzle: Select the appropriate orchestration service (e.g., Step Functions, EventBridge) based on workflow complexity and monitoring needs.