認識 Redshift:欄式資料庫

Redshift 入門

Jason Myers

Principal Architect

Redshift 概覽

  • 分散式
  • 欄式資料庫
  • 採用 PostgreSQL 9 語法並有所強化
  • 提供無伺服器與預先佈建叢集

Redshift 標誌

Redshift 入門

欄式 vs. 列式資料庫

列式(Row-based)

列式資料庫範例

欄式(Columnar)

欄式資料庫範例

Redshift 入門

Redshift 在 AWS 生態系中的位置

  • 主要的 SQL 資料倉儲
  • 可作為 AWS 環境的核心,支援 data lakehouse 能力
  • 支援外部 schema 於
    • AWS RDS for PostreSQL
    • AWS Aurora PostgreSQL-compatible edition
    • Amazon EMR(支援 Hive)
    • Amazon Kinesis(支援串流資料)
Redshift 入門

Redshift 在 AWS 生態系中的位置

  • 與其他 AWS RDS 資料庫等進行同盟查詢(Federated queries)
  • 透過 Redshift ML 與 Amazon SageMaker 整合,強化資料科學工作。
Redshift 入門

競品

  • Snowflake、BigQuery、Databricks Lakehouse、Azure Synapse Analytics

優點

  • 深度整合 AWS:與其他服務資料共享免複製
  • 無共享(share-nothing)架構
  • 針對重複查詢最佳化
  • 保留執行個體(RI)定價

缺點

  • 僅限 AWS
  • 未最佳化的查詢效能
  • 支援外部檔案的彈性需額外付費
Redshift 入門

檢視資料庫與綱要(schema)

  • 使用 SVV_REDSHIFT_SCHEMAS(內部)或 SVV_ALL_SCHEMAS(內部與外部)
-- 檢視資料庫與綱要名稱及綱要型別
SELECT database_name, 
       schema_name, 
       schema_type 
  -- 來自內部綱要檢視
  FROM SVV_REDSHIFT_SCHEMAS;
database_name        | schema_name         | schema_type
=====================|=====================| ===========
datacamp_course_prod | information_schema  | local
datacamp_course_prod | pg_catalog          | local
datacamp_course_prod | public              | local
dev                  | information_schema  | local
dev                  | pg_catalog          | local
dev                  | public              | local
Redshift 入門

檢視綱要中的資料表

  • 使用 SVV_REDSHIFT_TABLES(內部)或 SVV_ALL_TABLES(內部與外部)
-- 檢視資料表名稱
SELECT table_name 
  -- 使用同時包含內部與外部資料表的檢視
  FROM SVV_ALL_TABLES
 -- 位於外部的 spectrumdb 綱要
 WHERE schema_name = 'spectrumdb';
table_name            
======================
ecommerce_sales
global_power_plant_db
coffee_county_weather
idaho_site_id         
idaho_samples
Redshift 入門

一起來練習吧!

Redshift 入門

Preparing Video For Download...