ภายใน Redshift warehouse

Introduction to Redshift

Jason Myers

Principal Architect

หัวข้อ

  • โครงสร้างภายใน Redshift cluster
    • ประเภทของ node
    • ฟังก์ชันเฉพาะของ leader
    • พื้นที่จัดเก็บของ Redshift cluster
  • Predicates
  • Redshift spectrum
    • องค์ประกอบของฐานข้อมูล
    • ตาราง external
Introduction to Redshift

สถาปัตยกรรมของ Redshift cluster

Leader Node

  • รับการเชื่อมต่อ
  • สร้างและกระจาย query execution plan
  • รันคิวรีได้ทั้งหมดด้วยตัวเอง
  • มีฟังก์ชันเฉพาะของตัวเอง

Compute Node

  • จัดเก็บข้อมูล
  • รันโค้ดจาก leader node กับข้อมูลที่จัดเก็บไว้ในเครื่อง

Redshift Cluster

Introduction to Redshift

ฟังก์ชันเฉพาะของ leader

  • รันได้เฉพาะบน leader
-- Selecting the substr, starting at 
-- position 11 of 'chocolate chip'
SELECT SUBSTR('chocolate chip', 11);
chip
  • แนะนำให้ใช้ SUBSTRING แทน
  • ดูรายการฟังก์ชันเฉพาะของ leader ได้ใน เอกสาร AWS Redshift
  • SUBSTR จะเกิดข้อผิดพลาดเมื่อใช้กับคอลัมน์ในตาราง
-- Selecting the substr from position 1
-- of the column named field on table
SELECT SUBSTR(field, 1) FROM table;
ERROR: SUBSTR() function is not 
supported (Hint: use SUBSTRING 
instead)
Introduction to Redshift

ดูข้อมูลในแต่ละ node

SELECT host, 
       -- Calculate the percentage of used space
       -- using the used minus tossed or ready to be reclaimed
       -- divided by the capacity
       (used - tossed) / capacity * 100 as percent_used 
  FROM STV_PARTITIONS;
 host |  percent_used
======+==============
  0   |  24.9
  1   |  24.8
Introduction to Redshift

Predicates

SELECT table_A.columnX,
       table_B.columnY,
  FROM table_A
       INNER JOIN table_B 
          -- predicate
       ON table_B.foreign_key = table_A.primary_key 
       -- predicate
 WHERE table_B.columnZ = 'value';
  • มักเป็น boolean expression และพบใน clause WHERE, HAVING หรือ ON ของ SQL
Introduction to Redshift

Predicate push-down

PushDown

Introduction to Redshift

องค์ประกอบภายในของฐานข้อมูลทั่วไป

Database Components

MetaData Catalog

  • เก็บข้อมูล schema (คอลัมน์, key ฯลฯ)
  • อ้างอิงตำแหน่งที่จัดเก็บข้อมูล

Query Engine

  • วางแผนและรันคิวรี
  • รับการเชื่อมต่อ

Storage

  • จัดเก็บข้อมูลในตาราง
  • รองรับรูปแบบไฟล์และตารางหลายประเภท
Introduction to Redshift

สถาปัตยกรรมของ Redshift spectrum

AWS Glue Data Catalog

  • จัดเก็บข้อมูลเกี่ยวกับตาราง "external"

AWS S3 Bucket

  • จัดเก็บไฟล์ที่แทนตาราง
  • รองรับ CSV, JSON, Text, Parquet และรูปแบบไฟล์อื่นอีกมาก

Redshift Spectrum Architecture

Introduction to Redshift

มาฝึกกันเถอะ!

Introduction to Redshift

Preparing Video For Download...