Integrated Querying of SQL database data and S3 data in Amazon Redshift

Mengchu Cai, Martin Grund, Anurag Gupta, Fabian Nagel, Ippokratis Pandis, Yannis Papakonstantinou, Michalis PetropoulosIEEE Data Eng. Bull 2018

Introduction

Modern data architectures often grapple with a "split-brain" dilemma: high-performance, structured data resides in relational databases like Amazon Redshift, while massive volumes of raw or semi-structured data are stored in object storage "data lakes" such as Amazon S3. Traditionally, analyzing these disparate sources required slow and expensive Extract, Transform, Load (ETL) processes to move data into the database.

Amazon Redshift Spectrum addresses this challenge by providing an integrated, in-place querying system. It allows users to execute standard SQL queries that seamlessly join local relational tables with exabyte-scale S3 tables. By treating S3 as a collection of external tables, Redshift Spectrum enables massive-scale analysis without the need for prior data loading.

System Architecture

The core of the system is a multi-tenant execution layer that sits between the Redshift cluster and S3. This architecture employs a mediator approach to intelligently distribute query tasks.

Amazon Redshift Spectrum Architecture

As shown in the architecture diagram, the system consists of three primary layers:

  1. Redshift Leader Node: Acts as the query planner and optimizer.
  2. Redshift Compute Nodes: Coordinate execution and manage local data.
  3. Spectrum Nodes: A fleet of stateless compute resources that perform push-down operations directly against S3 data.

Query Execution and Optimization

To maximize efficiency and minimize network traffic—the primary bottleneck in cloud querying—Redshift Spectrum employs several sophisticated optimization techniques:

  • Aggregation Pushdown: Spectrum nodes perform "pre-aggregation" on the fly, returning only summarized results to the Redshift cluster rather than raw data.
  • Partial Aggregation: Because Spectrum nodes are stateless and diskless, they use a streaming approach for large groupings. If a grouping table exceeds memory, the node "evicts" partial results to Redshift compute nodes, which then perform the final merge using their local disks.
  • Dynamic Semijoin Reduction: The system uses results from small local tables (e.g., specific regions or product IDs) to create filters that are pushed to Spectrum, drastically reducing the volume of S3 data scanned.
  • Smart Partitioning: By mapping SQL join conditions directly to S3 object prefixes, the system can prune the search space and skip irrelevant files entirely.
Integrated Query Execution Plan

The execution plan illustrates how complex queries are decomposed. A "Spectrum (sub)query" is formulated to handle the heavy lifting of scanning and filtering S3 data, while the Redshift cluster manages the final joins and aggregations with local dimension tables.

Scalability and Performance

Redshift Spectrum decouples storage from compute, allowing for near-instant scaling. Users can query data volumes that would be physically impossible to fit into a standard database cluster. The system supports various file formats, including columnar (Parquet, ORC) and row-wise (CSV, JSON) formats, providing flexibility for diverse data lake environments. By pushing filters and aggregations down to the data, the system reduces network transfer by orders of magnitude, ensuring high performance even at exabyte scales.

Current Limitations

While powerful, the stateless nature of Spectrum nodes introduces certain constraints. Extremely high-cardinality groupings can place a heavy burden on Redshift compute nodes due to the memory limits of Spectrum nodes. Additionally, because Spectrum nodes do not communicate with each other, large-scale joins between two different S3 tables must currently be handled by the Redshift compute nodes. Finally, the system must constantly manage SQL parity, as the mediator layer ensures full SQL support even when underlying Spectrum nodes have more limited functional sets.

Summary updated

BibTeX
@article{cai2018integrated,
  author = {Mengchu Cai and Martin Grund and Anurag Gupta and Fabian Nagel and Ippokratis Pandis and Yannis Papakonstantinou and Michalis Petropoulos},
  title = {{Integrated Querying of SQL database data and S3 data in Amazon Redshift}},
  journal = {IEEE Data Eng. Bull.},
  year = {2018},
}
Figure