Snowflake

Snowflake Hybrid Tables: Designing Unified OLTP+OLAP Workloads

2026-03-26
更新: 2026-03-27
NicheeLab Editorial Team

Hybrid Tables are the centerpiece of Snowflake's Unistore architecture, a table type that delivers low-latency row-level operations (OLTP) and large-scale analytical queries (OLAP) on the same table. A PRIMARY KEY is mandatory, and the combination of row-oriented storage and indexes lets single-row lookups and point updates complete in milliseconds.

Hybrid Tables Architecture

通常テーブル (Standard Table)
  └─ 列指向マイクロパーティション
       └─ 大規模スキャン・集計に最適化
       └─ 単一行ルックアップは非効率

Hybrid Table
  ├─ 行指向ストレージ(主キーインデックス付き)
  │    └─ 単一行 SELECT / UPDATE / DELETE がミリ秒で完了
  │    └─ 参照整合性制約(FOREIGN KEY)をサポート
  │
  └─ 列指向ストレージ(バックグラウンド同期)
       └─ SELECT * / 集計クエリはこちらから読み取り
       └─ Snowflakeが自動的に行→列の同期を実行

CREATE HYBRID TABLE Syntax

-- 基本的なHybrid Table(主キー必須)
CREATE OR REPLACE HYBRID TABLE app_db.public.users (
  user_id INT PRIMARY KEY,
  email VARCHAR(255) NOT NULL UNIQUE,
  display_name VARCHAR(100),
  status VARCHAR(20) DEFAULT 'active',
  created_at TIMESTAMP_NTZ DEFAULT CURRENT_TIMESTAMP(),
  last_login TIMESTAMP_NTZ,
  metadata VARIANT
);

-- 複合主キーのHybrid Table
CREATE OR REPLACE HYBRID TABLE app_db.public.user_sessions (
  user_id INT,
  session_id VARCHAR(64),
  started_at TIMESTAMP_NTZ DEFAULT CURRENT_TIMESTAMP(),
  expires_at TIMESTAMP_NTZ,
  ip_address VARCHAR(45),
  user_agent VARCHAR(500),
  PRIMARY KEY (user_id, session_id),
  FOREIGN KEY (user_id) REFERENCES app_db.public.users(user_id)
);

-- セカンダリインデックスの追加
CREATE INDEX idx_users_email ON app_db.public.users (email);
CREATE INDEX idx_sessions_expires ON app_db.public.user_sessions (expires_at);

Primary Key Design Guidelines

AspectRecommendedAvoid
Data typeINT, BIGINT, VARCHAR (short fixed length)VARCHAR (long variable length), VARIANT
CardinalityHigh-cardinality values (UUID, sequence)Low-cardinality columns (status, region)
Number of columnsComposite keys of 1-3 columnsComposite keys of 4+ columns (index size grows)
ImmutabilityColumns whose values do not changeFrequently updated columns

DML Operation Patterns

-- 単一行の挿入(低レイテンシ)
INSERT INTO app_db.public.users (user_id, email, display_name)
VALUES (1001, '[email protected]', 'Alice');

-- 主キーによるポイント更新(ミリ秒レベル)
UPDATE app_db.public.users
SET last_login = CURRENT_TIMESTAMP(), status = 'active'
WHERE user_id = 1001;

-- 主キーによる単一行削除
DELETE FROM app_db.public.users WHERE user_id = 1001;

-- MERGE(upsert): アプリケーション側のidempotency確保
MERGE INTO app_db.public.users t
USING (SELECT 1001 AS user_id, '[email protected]' AS email, 'Alice' AS name) s
ON t.user_id = s.user_id
WHEN MATCHED THEN UPDATE SET t.last_login = CURRENT_TIMESTAMP()
WHEN NOT MATCHED THEN INSERT (user_id, email, display_name) VALUES (s.user_id, s.email, s.name);

-- 分析クエリ(OLAP)も同一テーブルで実行可能
SELECT
  DATE_TRUNC('DAY', created_at) AS signup_date,
  COUNT(*) AS new_users,
  COUNT_IF(status = 'active') AS active_users
FROM app_db.public.users
GROUP BY signup_date
ORDER BY signup_date DESC;

Concurrency Control and Locking

Hybrid Tables include a row-level locking mechanism. Standard Snowflake tables handle concurrency via snapshot isolation (MVCC) at the micro-partition level, but Hybrid Tables take pessimistic locks at the row level and serialize concurrent updates to the same row.

  • Concurrent DML on different rows runs in parallel
  • Concurrent UPDATEs on the same row will wait for the lock
  • Deadlock detection automatically aborts one of the transactions involved
  • Read queries (SELECT) do not take locks and therefore do not block writes

Referential Integrity Constraints

-- FOREIGN KEY制約(Hybrid Tables間でのみ有効)
CREATE OR REPLACE HYBRID TABLE app_db.public.orders (
  order_id INT PRIMARY KEY AUTOINCREMENT,
  user_id INT NOT NULL,
  total_amount NUMBER(12,2) NOT NULL,
  order_status VARCHAR(20) DEFAULT 'pending',
  created_at TIMESTAMP_NTZ DEFAULT CURRENT_TIMESTAMP(),
  FOREIGN KEY (user_id) REFERENCES app_db.public.users(user_id)
);

-- NOT NULL, UNIQUE, DEFAULT 制約もサポート
-- ただしCHECK制約は未サポート

Standard Tables vs. Hybrid Tables

CharacteristicStandard TableHybrid Table
Storage formatColumnar (micro-partitions)Row-oriented + columnar (background sync)
Primary keyOptional (constraint only, not enforced)Mandatory (enforced as an index)
FOREIGN KEYSyntactically supported but not enforcedReferential integrity is actually enforced
IndexesNonePrimary key index + secondary indexes
Single-row lookupFull scan or pruningMillisecond-level response via indexes
Concurrency controlMVCC (snapshot isolation)Row-level locking
Clustering KeysSupportedNot supported
Time TravelSupportedLimited

Limitations and Caveats

  • A PRIMARY KEY definition is mandatory; you cannot create a Hybrid Table without one
  • Clustering Keys cannot be set
  • Materialized Views cannot be created
  • FOREIGN KEYs are only valid between Hybrid Tables (not between Hybrid and standard tables)
  • Time Travel and Fail-safe behavior may differ from standard tables
  • Better suited to small, high-frequency DML than large batch INSERTs of millions of rows

Best Practices

  • Only use Hybrid Tables for OLTP-style tables: Limit to tables that are dominated by point operations, such as user masters, session management, and inventory counters.
  • Keep using standard tables for large-scale analytics: For fact tables with billions of rows, standard tables plus Clustering Keys are the right fit.
  • Add secondary indexes carefully: More indexes mean slower DML, so limit them to the columns that are queried frequently.
  • Enforce data integrity with FOREIGN KEYs: Enforce integrity at the database layer in addition to the application layer to keep inconsistent data out.

Check Your Understanding

Data Architecture

問題 1

You want to build a web application's user session management table in Snowflake. You need low-latency single-row lookups by user_id, and you also run daily aggregate queries for session statistics. Which table design is most appropriate?

  1. Create a standard table with CLUSTER BY (user_id) and rely on partition pruning for speed
  2. Create a Hybrid Table with a primary key and run both OLTP operations and OLAP aggregates on the same table
  3. Create a Transient Table and disable Time Travel to prioritize performance
  4. Use an External Table and store Parquet files partitioned by user_id

正解: B

When you need both single-row lookup by user_id (OLTP) and aggregate queries (OLAP), Hybrid Tables are the best fit. The primary key index lets single-row access complete in milliseconds, and the columnar storage synced in the background handles aggregate queries efficiently. Clustering Keys on a standard table optimize range filters and are not sufficient to deliver low-latency point lookups.

Frequently Asked Questions

What types of indexes can I use on Hybrid Tables?

Hybrid Tables automatically create an index on the PRIMARY KEY. You can also add secondary indexes with the CREATE INDEX statement, and UNIQUE INDEXes are supported as well. Standard Snowflake tables have no concept of indexes, so this is unique to Hybrid Tables. Keep in mind that adding indexes increases storage overhead and impacts DML performance, so keep them to the minimum required.

Can I set Clustering Keys on Hybrid Tables?

No, Clustering Keys cannot be set on Hybrid Tables. Hybrid Tables use a row-oriented storage structure and accelerate queries via primary key and secondary indexes. This is a different storage architecture from Clustering Keys, which assume the columnar micro-partition layout. The basic rule of thumb: use standard tables with Clustering Keys for OLAP workloads, and Hybrid Tables for mixed OLTP+OLAP workloads.

Can Hybrid Table data be replicated to other Snowflake regions?

Hybrid Tables can be replicated via database replication (failover groups), but with several constraints. At the replication target, Hybrid Tables are read-only and DML operations can only be executed in the primary region. Replication lag also means immediate visibility of the latest data is not guaranteed. If you need real-time consistency, design your application to keep its connection on the primary region.

Check what you learned with practice questions

Practice with certification-focused question sets

無料で問題を解いてみる
Author

NicheeLab Editorial Team

NicheeLab editorial team focused on data engineering and cloud certification learning. Content is structured around practical study needs and official exam domains.


Related articles
Snowflake

Snowflake Certifications: All 11 Exams Explained (2026)

Every SnowPro certification — Associate, Core, Specialty, Ad...

Snowflake

Snowflake Exam Difficulty Ranking: All 11 Certs Compared (2026)

All 11 SnowPro exams ranked by difficulty with study-time es...

Snowflake

Snowflake Study Guide: Fastest Pass Route by Exam (2026)

How to pass SnowPro certifications efficiently — official ma...

Snowflake

SnowPro Core (COF-C03): Complete Exam Guide (2026)

Pass the SnowPro Core exam — six domains, scope, sample ques...

Snowflake

SnowPro Associate Platform (SOL-C01): Complete Guide (2026)

The entry-level SnowPro Associate exam — scope, weighting, s...

Browse all Snowflake articles (103)
© 2026 NicheeLab All rights reserved.