What is a columnar table

Updated at:

As business data volumes surge, the storage cost and analytical efficiency of massive datasets become core challenges for many enterprises. To address this challenge, PolarDB for MySQL provides the X-Engine columnar table feature. Built on columnar storage, efficient compression, and parallel computing, this feature reduces your data storage cost to 10% of the raw data size and improves analytical query performance by an order of magnitude. It enables low-cost archiving of massive data and high-performance real-time analytics while remaining fully compatible with the MySQL ecosystem.

Enable columnar table analysis

Enable columnar analysis for an existing cluster

Note

PolarDB for MySQL's columnar table analysis feature is supported only for MySQL 8.0.2, and the minor kernel version must be 8.0.2.2.34 or later. If your cluster does not meet these version requirements, upgrade the minor kernel version first, and then enable the columnar table analysis feature.

  1. Log in to the PolarDB console,In the navigation pane on the left, click Clusters. Select the Region where the cluster is deployed, and then click the cluster ID to go to the cluster details page。

  2. On the Basic Information page, find Column-Oriented Table Analysis Acceleration and click the Enable button to its right. After the cluster restarts, the columnar table analysis feature is enabled.

Enable columnar analysis when purchasing a new cluster

  1. Log on to the PolarDB console. In the left-side navigation pane, click Clusters. Select the region where the cluster resides, and then click Create Cluster.

  2. On the purchase page, configure the following key settings:

    1. Creation Method: Create Primary Cluster

    2. Engine Version: MySQL 8.0.2

    3. Column-Oriented Table Analysis Acceleration: Enable

  3. Configure the other settings based on your business requirements and complete the purchase. For more information, see Custom purchase

Before you enable columnar table acceleration for an existing cluster, review the following impacts.

  • Enabling columnar table acceleration for an existing cluster causes the cluster to restart.

  • The default table storage engine changes from InnoDB to X-Engine, which is better suited for archival analytics.

  • By default, 90% of memory resources are reserved for X-Engine and 10% are allocated to InnoDB.

Overview

X-Engine columnar tables use a compute-storage decoupled architecture. Compute resources and storage resources scale independently and elastically, delivering petabyte-level processing capacity for massive data. The storage layer is built on a distributed file system and Object Storage Service (OSS). The compute layer delivers high-performance analytics through deep optimization of the query optimizer, execution operators, and storage engine.

Technical architecture

PolarDB overall architecture

PolarDB uses a compute-storage decoupled architecture built on a distributed storage layer. The ParallelRaft protocol ensures consistency across multiple replicas, and OSS is transparently supported. Compute nodes consist of one read/write node (RW) and one or more read-only nodes (RO), and support both the InnoDB and X-Engine engines. A database proxy acts as a bridge between applications and compute nodes, providing read/write splitting and load balancing.

image

Columnar table architecture

image

Its core technical components include:

  • Query optimizer: A built-in cost-based optimizer (CBO) for hybrid row-column storage intelligently evaluates the cost of each query request and automatically selects the optimal execution plan (choosing between row storage and column storage).

  • Execution operator: Column-oriented vectorization and parallel execution technologies significantly accelerate analytical queries on single tables and multi-table joins in batch processing mode.

  • Storage engine: Supports real-time transactional updates. The primary table uses columnar storage and relies on the Non-Clustered Index (NCI) component to guarantee fast updates. A delete-mask mechanism marks deleted data, which provides efficient parallel queries without affecting real-time writes. In addition, row-store secondary indexes quickly filter out invalid data to further improve query efficiency.

Solution comparison

To help you understand and select the appropriate table type, the following table compares the key differences between traditional row-oriented tables (such as InnoDB) and PolarDB columnar tables:

Aspect

Row-oriented table (X-Engine)

Columnar table

Data organization

Data is stored contiguously by row. All columns of a row are stored together.

Data is stored contiguously by column. All values of a column are stored together.

Data compression ratio

Medium. Compared with InnoDB, data can be compressed to at most 3/10 of its original size.

High. With columnar storage and specialized encoding such as dictionary encoding, data can be compressed to 1/10 of its original size compared with InnoDB.

Query performance

High point-query performance. Suitable for scenarios that read a single row or a few rows quickly by primary key or index (OLTP).

Strong analytical performance. Only the columns involved in a query are read, which effectively reduces I/O. Combined with vectorized parallel computing, aggregate analytical performance is an order of magnitude higher than that of row-oriented tables.

Update and delete performance

High. Rows are located and modified directly.

Relatively low. Real-time updates are supported, and the NCI component quickly locates the records to be modified.

Scenarios

Online Transaction Processing (OLTP), such as high-concurrency insert, delete, update, and query operations.

Online Analytical Processing (OLAP), such as data archiving, report generation, ad hoc queries, and aggregate analysis of massive data.

Benefits

  • High cost-effectiveness: Columnar storage, efficient encoding, and high-compression algorithms, combined with the low-cost storage media of OSS, reduce the storage and processing cost of massive data by 90%.

  • High-performance real-time analytics: Data is available for analytical queries immediately after it is written. Multi-core parallelism, vectorization, and MPP technology deliver query performance comparable to specialized analytical databases, meeting demanding real-time analytics requirements.

  • 100% MySQL compatible: Provides a data type system and protocol consistent with MySQL and supports flexible type conversion, so your existing applications and tools can connect without modification.

  • Independent elastic scaling: The compute-storage decoupled architecture allows compute nodes and storage space to scale independently on demand, easily handling business peaks and data growth.

  • Powerful wide table support: A single table supports up to 10,000 columns, meeting business requirements for large wide table storage and high-concurrency writes.

  • Excellent ease of use: Supports high-compression storage and high-performance analytics within a single database engine and provides full DDL and DML operations, simplifying your technology stack and operations management.

Use cases

Low-cost archiving of massive historical data

  • Pain point: As your business grows, historical data such as orders, logs, and transaction records in core databases expands rapidly and occupies a large amount of expensive storage space. Traditional data migration solutions can reduce costs, but they take data offline so that it cannot be queried online directly, which increases the complexity of data usage.

  • Solution: Use columnar tables for online data archiving. You can migrate cold data from row-oriented tables (InnoDB) or entire historical data tables to columnar tables within the same PolarDB cluster.

  • Core value:

    • Sharp cost reduction: A compression ratio of up to 10:1 and the use of low-cost storage media such as OSS reduce storage costs by 90%.

    • Data stays online: Archived data always remains online and available. You can query and analyze it with standard SQL at any time, without a complex data restoration process.

    • Transparent to your business: At the application layer, a columnar table is just a regular MySQL table, so no changes are required.

Build a dedicated data warehouse

  • Pain point: When enterprises build a dedicated data warehouse, they often face high hardware costs, complex data synchronization pipelines (ETL), and a high operations barrier, especially when a new technology stack such as ClickHouse is introduced.

  • Solution: Relying on the massive data storage capacity of PolarStore, you can consolidate data from multiple upstream data sources and store it uniformly in X-Engine columnar tables. This gives you massive, low-cost storage capacity together with real-time aggregate analytical performance.

  • Core value:

    • Significantly lower cost and complexity: You can build a data warehouse within the familiar MySQL ecosystem without purchasing expensive specialized hardware or introducing a heterogeneous analytical system, which effectively simplifies your technology stack and operations management.

    • Real-time data analytics: Upstream data can be consolidated into columnar tables in real time for analysis, which avoids the T+1 data latency of traditional ETL solutions.

    • Massive data processing capacity: The X-Engine storage architecture and efficient compression enable low-cost storage and processing of petabyte-scale massive data.

Federated query analysis

  • Pain point: The business data of an enterprise is usually stored in a distributed manner. Part of the data resides in online databases such as PolarDB, while the rest is stored in open formats such as Parquet and ORC in Object Storage Service (OSS). To analyze these two parts of data together, a complex ETL process is usually required to import the OSS data into the database.

  • Solution: Use the PolarDB foreign table feature to directly access data in OSS.

  • Core value:

    • In-place analysis: Without moving or importing data, create a foreign table in PolarDB for the files in OSS, and then query them with SQL.

    • Federated queries: You can easily use PolarDB local tables (row-oriented or columnar) together with OSS foreign tables in JOIN operations to achieve unified analysis of online and offline data.

Performance test report

The following performance data was obtained in a specific test environment and provides a reference for evaluating the benefits of columnar tables.

Note

The TPC-H implementation in this topic is based on TPC-H benchmarking. These test results cannot be compared with published TPC-H benchmark results because the tests do not fully meet all TPC-H requirements.

Data loading performance

The following data is based on a test environment with 32 cores and 256 GB of memory. It uses the TPC-H and Airline datasets to compare columnar tables with ClickHouse and Doris in terms of data loading and storage.

Loading speed

  • TPC-H dataset: The loading speed of columnar tables reaches 5.71 million rows per second with a write throughput of 50 GB/min, which is approximately 2.7 times that of ClickHouse.

  • Airline dataset: The loading speed of columnar tables reaches 4.3 million rows per second with a write throughput of 27 GB/min, which is approximately 2 times that of ClickHouse.

Dataset

ClickHouse (million rows/sec)

Doris (million rows/sec)

Columnar table (million rows/sec)

TPC-H

2.10

4.54

5.71

Airline

1.40

2.15

4.30

Storage space

  • TPC-H dataset: With 100 GB of raw data, columnar tables achieve a compression ratio of 4x.

  • Airline dataset: With 75 GB of raw data, columnar tables achieve a compression ratio of 18x.

The following table compares the storage space of the Airline dataset (75 GB of raw data):

Type/Product

ClickHouse

Doris

Columnar table

Storage space (GB)

9.29

4.49

3.97

Compression ratio

Approx. 8x

Approx. 16x

Approx. 18x

TPC-H query performance

  • In the performance test with the TPC-H 100 GB dataset, the total time for columnar tables to run all 22 queries was 17.994 seconds, compared with 76.9 seconds for ClickHouse. The overall performance of columnar tables was approximately 4.3 times that of ClickHouse.

    Query

    Columnar table (seconds)

    ClickHouse (seconds)

    Q1

    1.175

    2.2

    Q2

    0.178

    0.9

    Q3

    0.577

    1.6

    Q4

    0.433

    1.3

    Q5

    0.522

    3.3

    Q6

    0.366

    0.32

    Q7

    0.633

    1.7

    Q8

    0.528

    1.8

    Q9

    2.817

    12

    Q10

    0.935

    2.3

    Q11

    0.218

    0.66

    Q12

    0.535

    1.4

    Q13

    1.255

    4.4

    Q14

    0.442

    0.3

    Q15

    0.889

    0.42

    Q16

    0.553

    0.6

    Q17

    0.738

    4.2

    Q18

    2.381

    4.3

    Q19

    0.759

    2

    Q20

    0.453

    0.6

    Q21

    1.308

    29.6

    Q22

    0.299

    1

    Total

    17.994

    76.9

  • Multi-node parallel analysis: In the performance test with the TPC-H 1 TB dataset, columnar tables used multi-node parallel acceleration, which reduced the total query time from 1420.551 seconds on a single node to 167.948 seconds on six nodes.

    Query

    1 node (seconds)

    2 nodes (seconds)

    4 nodes (seconds)

    6 nodes (seconds)

    Q1

    76.849

    36.831

    23.031

    20.022

    Q2

    5.841

    2.805

    1.527

    1.09

    Q3

    133.69

    26.131

    15.833

    4.75

    Q4

    51.466

    19.02

    3.353

    2.362

    Q5

    52.965

    26.844

    13.715

    4.269

    Q6

    34.577

    21.831

    35.17

    11.274

    Q7

    75.996

    29.659

    17.279

    5.717

    Q8

    54.989

    28.922

    15.651

    3.375

    Q9

    155.33

    78.216

    40.38

    25.983

    Q10

    72.222

    31.659

    17.177

    4.594

    Q11

    4.149

    2.049

    1.351

    1.069

    Q12

    50.997

    27.79

    16.207

    2.977

    Q13

    73.009

    31.742

    17.605

    16.255

    Q14

    36.887

    22.093

    4.475

    3.778

    Q15

    66.217

    38.628

    7.583

    6.451

    Q16

    11.493

    4.49

    2.528

    1.758

    Q17

    59.225

    37.101

    11.434

    8.767

    Q18

    132.604

    53.578

    17.164

    10.797

    Q19

    72.794

    38.416

    23.759

    16.651

    Q20

    42.621

    22.432

    5.62

    4.768

    Q21

    149.245

    54.803

    12.758

    8.793

    Q22

    7.385

    5.684

    2.972

    2.448

    Total

    1420.551

    640.724

    306.572

    167.948