Unlike Amazon Athena, Amazon Redshift physically stores data inside the data warehouse. It is designed specifically for Online Analytical Processing (OLAP) workloads and uses Massively Parallel Processing (MPP) along with columnar storage to achieve high query performance.
1. Stores Data
What does it mean?
Amazon Redshift is a database, meaning it physically stores your tables and data.
For example:
CREATE TABLE sales (
sale_id INT,
customer_id INT,
amount DECIMAL(10,2),
sale_date DATE
);
When data is loaded,
COPY sales
FROM 's3://company-data/sales/'
IAM_ROLE 'arn:aws:iam::123456789012:role/redshift-role'
FORMAT AS PARQUET;
the data is copied into Redshift's storage.
Unlike Athena,
Athena → reads data directly from S3.
Redshift → stores data inside the warehouse.
Internal Architecture
Client
│
▼
Amazon Redshift
-------------------
sales table stored
customer table stored
product table stored
inventory table stored
The data remains inside Redshift until:
DELETE
TRUNCATE
DROP TABLE
VACUUM (reclaims deleted space)
Interview Point
Redshift is a storage + compute engine.
Athena is only a query engine.
2. Columnar Storage
If you execute >> SELECT SUM(salary) FROM sales;
Redshift reads only Salary Column instead of the entire row. This reduces disk I/O dramatically.
Advantages
✓ Reads only required columns
✓ Faster aggregation
✓ Better compression
✓ Less disk I/O
✓ Ideal for analytics
Columnar storage is one of the biggest reasons Redshift performs much faster than traditional row-oriented OLTP databases for analytical queries.
3. Compression
Because each column stores similar data types, compression becomes extremely effective.
Why compression is effective
Since every column contains similar values, patterns are easier to compress than in row storage.
Benefits
✓ Less storage
✓ Faster disk reads
✓ Better cache utilization
✓ Reduced network transfer
Compression Types
Redshift automatically selects the best encoding.
Common encodings include:
AZ64
LZO
ZSTD
BYTEDICT
DELTA
RUNLENGTH
Most modern Redshift clusters use Automatic Table Optimization, which chooses encodings automatically.
No comments:
Post a Comment