🟢 Easy
Redshift — Petabyte Data Warehouse
Fully managed, petabyte scale, part of AWS. From file: supports multiple databases per cluster, uses psycopg2 or boto3 via JDBC.
🟡 Intermediate
Architecture — MPP & Columnar
- Leader Node: manages client communication, coordinates, compiles/optimizes query plan, distributes data — does not store data, handles metadata
- Compute Nodes: store data and execute queries, each divided into slices handling a piece of data/workload
- MPP: massively parallel processing — each node works independently
- Columnar storage (like Parquet/ORC) — read-optimized for OLAP, large analytics
Parallel query execution: divides query into smaller parts executed in parallel across nodes.
🟡 Intermediate
Redshift Spectrum vs Athena
| Athena | Redshift Spectrum |
|---|---|
| Serverless, fully managed, query S3 directly via Glue Catalog/RDS | Extension of Redshift, servers managed in cluster, mixes Redshift + S3 |
| Ad-hoc analysis/validation | Join S3 tables with Redshift tables without importing |
🔴 Advanced
Distribution Styles
| Style | When |
|---|---|
| Key — distribute by specific column | Frequently joined data |
| Even — evenly across slices | No key to distribute on |
| All — copy entire table to every slice | Small tables, no shuffling (joins within slice) |
🔴 Advanced
Sort Keys
Defines order data is stored on disk within each compute node.
- Compound: one or more columns in listed order — e.g.,
sortkey(orderdate, productid, region)effective when filtering/sorting on leading columns - Interleaved: balanced order for multiple columns — e.g., sales table frequently queried by region, orderdate, productid with no priority → use interleaved
SQL
CREATE TABLE sales(
orderid BIGINT,
custid BIGINT,
orderdate DATE,
amount DECIMAL(10,2)
)
DISTKEY(customerid)
SORTKEY(orderdate); -- or INTERLEAVED SORTKEY(orderdate, customerid);
🔴 Advanced
Optimization Techniques (from file)
- Right distribution style
- Proper sort keys
- Avoid SELECT * (column pruning)
- Predicate pushdown (WHERE early)
- VACUUM and ANALYZE (update statistics, reclaim space)
- Avoid unnecessary JOINs, prefer INNER over LEFT
- Partitioning data
Features: highly scalable, columnar, compression, MPP, cross-DB integration, automatic optimization. Limitations: not for small data, not real-time streaming, can be expensive.