列指向ストレージ/分析
Oracle
-- Database In-Memory: keep the table in memory in columnar format
ALTER TABLE sale INMEMORY;
-- With priority and compression:
ALTER TABLE sale INMEMORY PRIORITY HIGH
MEMCOMPRESS FOR QUERY HIGH;Oracle Database In-Memory(12.1.0.2+)は、ディスク上の行形式を維持しながら(デュアルフォーマット)、テーブルをメモリ上に列形式で保持する(In-Memory Column Store, IM)ことで分析クエリを高速化する。INMEMORY は別ライセンスのオプション。inmemory_size パラメータが IM 領域のサイズを決める。
PostgreSQL
-- Core PostgreSQL is row-based; columnar storage needs an extension:
-- Citus columnar access method:
CREATE EXTENSION IF NOT EXISTS citus;
CREATE TABLE sale_columnar (...) USING columnar;
-- Alternatives: the Hydra/cstore_fdw extensions.コアの PostgreSQL は行ベース(ヒープ)のストレージのみを提供する。列指向ストレージには Citus の 'columnar' アクセスメソッド(USING columnar)、Hydra、または旧来の cstore_fdw 拡張を使用する。これらは分析/データウェアハウスのワークロード向けに圧縮とスキャン速度を提供する。
MySQL
-- Not applicable: core InnoDB does not offer columnar storage.
-- For analytics: MySQL HeatWave (cloud, in-memory columnar)
-- or integration with external ClickHouse/Apache Doris.標準の MySQL(InnoDB)は行ベースで、組み込みのカラムストアはない。分析の高速化には MySQL HeatWave(Oracle Cloud のインメモリ列指向アクセラレータ)を使用する。オンプレミスでは通常、ClickHouse や Apache Doris などの外部の列指向エンジンを使用する。
SQL Server
-- Clustered columnstore index (for analytic tables):
CREATE CLUSTERED COLUMNSTORE INDEX cci_sale ON dbo.sale;
-- Nonclustered columnstore on a rowstore table (HTAP):
CREATE NONCLUSTERED COLUMNSTORE INDEX ncci_sale
ON dbo.sale (city, product, amount, created_at);SQL Server のカラムストアインデックス(2012 で読み取り専用の非クラスタ化、2014 で更新可能なクラスタ化、2016 で更新可能な非クラスタ化)はデータを高圧縮で列ごとに格納する。バッチモードと組み合わせると、集計/スキャン中心の分析クエリが大幅に高速化する。クラスタ化はデータウェアハウスに、非クラスタ化は HTAP に適する。
MongoDB
-- Not applicable: MongoDB is document (row-like) based.
-- For analytics: dedicated Analytics Nodes in Atlas
-- or export to a columnar format ($out)/an external engine.MongoDB はドキュメントを行に似た BSON として格納し、組み込みの列指向(カラムストア)ストレージはない。分析ワークロードには、Atlas レプリカセットの専用 Analytics Nodes、Atlas Data Federation、または列指向システム(例: Parquet)へのデータのエクスポートを使用する。
Redis
-- Not applicable: there is no concept of columnar storage.Redis はインメモリのキーバリューストアであり、行/列のストレージの区別はない。分析用の集計は Sorted Set、HyperLogLog(近似カウント)、RedisTimeSeries などの特殊な構造で行う。大規模な OLAP には適さない。
Elasticsearch
# doc_values: fields are stored column-wise on disk (enabled by default).
# Required for sorting/aggregation; active on non-text fields.
PUT sale
{ "mappings": { "properties":
{ "amount": { "type": "double", "doc_values": true } } } }ソートと集計のために、Elasticsearch はフィールドを doc_values というディスクベースの列指向構造に保持する(数値/keyword/date フィールドではデフォルトで有効)。この列指向のレイアウトが分析/集計クエリを高速化する。text フィールドではデフォルトで無効。