Help Center/ Data Warehouse Service/ Best Practices/ Data Development/ Selecting a Proper Table Type to Boost Development and Queries
Updated on 2026-07-02 GMT+08:00

Selecting a Proper Table Type to Boost Development and Queries

The way data is stored in a database significantly impacts the performance and efficiency of data processing. This section explains the table types DWS supports, categorizes them by storage format, outlines their uses, and offers basic examples for table selection and development.

Table Storage Formats

In terms of data storage structure, DWS supports row-store tables and column-store tables.

Hybrid row- and column-store tables are essentially column-store tables.

  • A row-store table stores each row as its smallest physical unit. In this format, all fields within a row are stored contiguously, including placeholders for null values. To find a complete row, you can use its unique row identifier (tid).

    An example of physical data storage in a row-store table:

    1
    2
    3
    4
    | ID  | Name  | Age | Salary | Department | 
    |-----|-------|-----|--------|------------|
    | 001 | Jack | 30 | 15000 | Technology Dept | Continuous storage of data in a row
    | 002 | John | 28 | 12000 | Marketing Dept |
    
  • A column-store table stores data by columns instead of rows. The values of each column are stored contiguously, one after the other. Separate columns are managed as distinct storage units.

    An example of physical data storage in a column-store table:

    1
    2
    3
    Column: ID       | 001 | 002 | 003 |...
    Column: Name  | Jack | John | Tom |...
    Column: Age      | 30 | 28 | 35 |...
    

Table Types Supported by DWS

Currently, DWS supports row-store tables, column-store 2.0 tables, HStore Opt tables, tables with decoupled storage and compute, and hybrid row- and column-store tables.

  • By default, DWS system tables and service tables are row-store tables.
  • Column-store 2.0 tables, HStore Opt tables, tables with decoupled storage and compute, and hybrid row- and column-store tables are all variations of column-store tables. These tables are evolved based on data column storage and apply to different scenarios.

Row-Store Tables

In a row-store table, you can quickly locate a specific data row using an index, and each operation reads at least an entire row at once.

Such a table offers several benefits due to its design.

  • Good point query performance: In a point query, the tuple of a row can be directly indexed.
  • High update efficiency: Row storage excels at handling real-time imports and concurrent updates.

However, there are some disadvantages:

  • High storage usage: Currently, DWS uses multiple versions to store data before and after updates. As a result, dirty data also occupies storage space.
  • Read amplification: Accessing only one or two columns from a wide table often results in high read amplification because it requires reading the entire page and all its tuples.

Row-store tables perform efficiently in traditional OLTP systems where tasks like adding, deleting, updating, and querying data are performed frequently.

Example:

1
2
3
4
5
6
-- Default type. Set ORIENTATION to ROW or retain the default value.
CREATE TABLE table_row
(
    c1 INT,
    c2 TEXT
) WITH (ORIENTATION = ROW);

Column-Store Tables

Row-store tables may face performance issues during analysis and complex queries, particularly with large datasets. In such cases, you can consider using column-store tables.

Column-store tables offer these benefits:

  • Efficient batch queries: Column storage performs better for analyzing specific columns, especially in large tables with many columns (for example, 1,000 columns).
  • Reduced storage space: Column storage supports high-compression rates due to uniform data types within each column.

For OLAP scenarios, you can prioritize column-store tables. For details about the use cases of column-store 2.0 tables, HStore Opt tables, tables with decoupled storage and compute (column-store 3.0 tables), and hybrid row- and column-store tables, see the following parts.

Column-Store 2.0 Tables

A column-store 2.0 table begins as a basic column-store table. Each column's data is grouped into a compression unit (CU) based on size. Once compressed, this data is stored in a physical file. A helper table manages transaction visibility at the CU level.

Column-store 2.0 tables have been widely used in many applications.

Example:

1
2
3
4
5
6
-- Set ORIENTATION to COLUMN.
CREATE TABLE table_col
(
    c1 INT,
    c2 TEXT                                     
) WITH (ORIENTATION = COLUMN);

HStore Opt Tables

Column-store 2.0 tables outperform row-store tables for large complex queries but have limitations. They do not support concurrent updates or imports since transaction visibility relies on CUs.

HStore Opt tables address these limitations by managing increasing workload complexity and meeting the growing need for real-time data updates and imports. They combine the benefits of both row-store tables and column-store tables. Built on column-store tables 2.0, HStore Opt tables improve concurrent import performance. Real-time changes like additions, deletions, and updates are performed in a row-store table, and then a background thread merges this data into the CUs. This ensures data compression and analysis capabilities.

In recent years, increasing demands for real-time processing have made HStore Opt tables more popular than column-store 2.0 tables.

Example:

1
2
3
4
5
6
--Set ENABLE_HSTORE_OPT to TRUE for a column-store table.
CREATE TABLE table_hstore
(
    c1 INT,
    c2 TEXT                                     
) WITH (ORIENTATION = COLUMN, ENABLE_HSTORE_OPT = TRUE);

Tables with Decoupled Storage and Compute

HStore Opt tables can process requests in real time. However, column-store tables have the AppendOnly feature, so frequent concurrent inserts or updates can quickly increase CU file sizes. The EVS storage is costly.

Tables with decoupled storage and compute resolve the issues by storing CU files on OBS (a low-cost, distributed object storage from Huawei). By utilizing local EVS disks as a cache, these tables maintain high read/write performance while significantly reducing costs. OBS allows you to scale up storage without limits and change compute resources quickly.

The tables are ideal for workloads that prioritize storage costs and elasticity.

Example:

1
2
3
4
5
6
7
-- Select a cluster with decoupled storage and compute.
-- Set COLVERSION to 3.0 for a HStore table.
CREATE TABLE table_v3
(
    c1 INT,
    c2 TEXT                                     
) WITH (ORIENTATION = COLUMN, ENABLE_HSTORE_OPT = TRUE, COLVERSION = 3.0);

Hybrid Row- and Column-Store Tables

Column-store tables 2.0, HStore Opt tables, and tables with decoupled storage and compute excel at batch queries, real-time imports, and space management, but still fall short of matching the point query speed of row-store tables. Hybrid row- and column-store tables save data in both row and column formats. This approach uses extra space but boosts point query speed.

The two formats are independently maintained and synchronously updated. The query optimizer selects an optimal way to access data by analyzing the query path. It leverages column storage's built-in filtering to automatically manage I/O path and choose between the row and column formats for data access. Hybrid row- and column-store tables combine the strong compression and high throughput of column storage with the flexible local data access of row storage.

Such tables work well for scheduling data in mixed queries. They lower total I/O costs, boost data hit ratios, and enhance query speed.

Example:

1
2
3
4
5
6
-- Set STORAGE_MODE to MIX for an HStore table.
CREATE TABLE table_mix
(
    c1 INT,
    c2 TEXT                                     
) WITH (ORIENTATION = COLUMN, ENABLE_HSTORE_OPT = TRUE, STORAGE_MODE = MIX);

Table Type Selection

Row and column storage each have their own unique advantages and disadvantages. Row storage excels in transaction processing, whereas column storage performs better for big data analysis. Advancing technology has blurred the line between row and column storage, prompting modern databases to adopt hybrid approaches for diverse requirements. When selecting a storage method for your database, you need to consider your specific use cases, query types, and desired performance.

Table 1 Differences of table types

Dimension

Row-Store Table

Column-Store 2.0 Table

HStore Opt Table

Table with Decoupled Storage and Compute

Hybrid Row- and Column-Store Table

Data storage

The attributes of a tuple are stored nearby.

The values of an attribute are stored nearby in the unit of CU.

Data is stored in the primary column-store tables as CUs. Data inserted in small batches and columns to be updated are serialized and then stored in a newly designed delta table.

Similar to an HStore table, the table saves CU files to OBS.

Data is stored in row and column formats.

Data write

Compression is not supported. Data is stored in its original form, occupying a large amount of disk space.

Compression is supported. Each column contains values of the same attribute, ensuring effective compression. Data write uses minimal I/O resources and saves disk space.

Data inserted in batches is directly written to CUs, which are as easy to compress data as column storage. Data inserted in small batches and columns to be updated are serialized and then compressed. They will also be periodically merged to primary table CUs.

Like an HStore table, the table saves CU data to OBS asynchronously.

Like an HStore table, the table stores data as CUs in both row and column formats, requiring more space. However, its compression feature makes it more compact than standard row-store tables.

Data update

Data is updated by row, avoiding CU lock conflicts. The performance of concurrent operations (UPDATE/UPSERT/DELETE) is high.

The entire CU needs to be locked even if only one record in it is updated. Generally, concurrent operations (UPDATE/UPSERT/DELETE) are not supported.

CU lock conflicts can be avoided. Concurrent operations (UPDATE/UPSERT/DELETE) run more than 60% as fast as those on a row-store table.

OBS has slower read and write speeds compared to local disks. To improve write performance, it uses asynchronous writes.

Its concurrent updates work like those in an HStore table.

Data read

Data is read by row. An entire row needs to be retrieved even if only one column in it needs to be accessed. The non-point query performance is poor.

When data is read by column, only the CU of a column needs to be accessed. CUs can be easily compressed, occupying less I/O resources and achieving high read performance for a single column.

Data in a primary column-store table is read by column. Data inserted in small batches and columns to be updated are deserialized and then retrieved. After data is merged to the primary table, the data can be read as easily as that in column storage.

The local disk cache speeds up data reads.

The query optimizer selects an optimal way to access data by analyzing the query path. Thanks to column storage's built-in filtering feature, the table enables smarter I/O path management and automatic selection of row or column format for data access.

Advantage

The concurrent update performance is high, and the point query capability is strong.

The query performance is high, and the disk space usage is small.

The concurrent update performance is high. After data merges, the query and compression performance match column storage efficiency.

The scaling capability is strong, and the storage cost is low.

Point queries work efficiently and space compression is supported. Its disk usage is smaller than that of a row-store table.

Disadvantage

A large amount of disk space is occupied, and the query performance is low.

Generally, concurrent updates are not supported.

A background permanent thread is required to clear unnecessary HStore table data after MERGE. Data is merged to the primary table CUs and then cleared. This operation is irrelevant to the SQL syntax MERGE.

The read and write speed of OBS is slower than that of local disks.

The disk usage is higher than that of column-store tables and HStore tables.

Scenario

OLTP transactions with frequent update and deletion operations. Point queries (simple queries that are based on indexes and return a small amount of data).

OLAP queries and analysis. Scenarios where a large volume of data is imported, and is rarely updated or deleted after the import.

High-concurrency updates and imports, and high-performance queries.

Systems requiring quick scaling or affordable storage.

Systems needing real-time data updates, big data query and analysis, and point query performance.