列式存储 / 分析
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 只提供基于行的(heap)存储。列式存储可使用 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)是基于行的,没有内置 columnstore。分析加速使用 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 columnstore 索引(2012 为只读非聚集;2014 为可更新聚集;2016 为可更新非聚集)以高压缩比按列存储数据;配合 batch mode,可大幅加速以聚合/扫描为主的分析查询。聚集型适合数据仓库,非聚集型适合 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 存储文档;没有内置的列式(columnstore)存储。分析负载可使用 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 的基于磁盘的列式结构中(numeric/keyword/date 字段默认启用)。这种列式布局可加速分析/聚合查询;text 字段默认禁用。