Skip to main content

Row Store

Row store stores an additional compact binary row-format copy alongside columnar storage. It can reduce separate column reads when an eligible query fetches many columns from a small number of rows.

VeloDB Cloud uses columnar storage, where values are organized by column. This works well for analytical queries that read only the required columns. A point query such as SELECT * on a wide table must fetch more columns, so separate column reads can add I/O work.

When row store is enabled, the system writes an additional row-form column containing all or selected columns. Eligible queries can fetch those values together. Actual I/O and latency depend on the query plan, page layout, and cache; row store also increases storage and ingestion work.

Applicable scenarios​

Row store mainly targets the following two query categories. Use the table below to quickly judge whether to enable it:

ScenarioTypical Query PatternTable Model RequirementRecommended
High-concurrency primary key point querySELECT ... FROM t WHERE pk1 = ? AND pk2 = ?Unique Key MOW tableRecommended
Wide-table TOPN querySELECT * FROM t [WHERE ...] ORDER BY ... LIMIT NDuplicate table / Unique Key MOW tableRecommended
Analytical queryAggregation, complex filtering on a few columns, and so on—Not recommended (columnar storage is sufficient)

The following sections describe the trigger conditions, table-creation methods, and query examples for each scenario.

Scenario 1: High-concurrency primary key point query​

This applies to high-concurrency scenarios on Unique Key MOW tables that look up specific rows by the full primary key. When the conditions are met, the query takes the Short-Circuit path and bypasses the regular execution pipeline.

Trigger conditions​

All of the following conditions must be met at the same time:

  1. The table is a Unique Key MOW table ("enable_unique_key_merge_on_write" = "true").
  2. Row store is enabled via "store_row_column" = "true" or "row_store_columns" = "...".
  3. The WHERE clause contains equality conditions on all primary key columns, joined by AND.
  4. The session permits short-circuit queries, and the query has a supported single-table plan shape. In the checked Core 26.1.3 planner, tables with VARIANT columns are excluded.

Cloud enables lightweight schema change through managed property handling. Check the execution plan to verify the optimization; row store alone is insufficient.

Table creation example​

The following example creates a table with eight columns, enables row store on five of them, and sets row_store_page_size to 4 KB as a value to evaluate:

CREATE TABLE `tbl_point_query` (
`k` int(11) NULL,
`v1` decimal(27, 9) NULL,
`v2` varchar(30) NULL,
`v3` varchar(30) NULL,
`v4` date NULL,
`v5` datetime NULL,
`v6` float NULL,
`v7` datev2 NULL
) ENGINE=OLAP
UNIQUE KEY(`k`)
COMMENT 'OLAP'
DISTRIBUTED BY HASH(`k`) BUCKETS 1
PROPERTIES (
"enable_unique_key_merge_on_write" = "true",
"light_schema_change" = "true",
"row_store_columns" = "k,v1,v3,v5,v7",
"row_store_page_size" = "4096"
);

Query example​

-- Query all columns
SELECT * FROM tbl_point_query WHERE k = 100;

-- Query a subset of columns
SELECT k, v1, v3, v5, v7 FROM tbl_point_query WHERE k = 100;

Handling partial-column row store: Columns omitted from the row-form copy still require columnar reads. Compare the two query plans above rather than assuming that a partial row store makes SELECT * a single physical I/O.

Verification method​

Run EXPLAIN on the query. The output should contain the SHORT-CIRCUIT marker. For details, see High-Concurrency Point Query.

Scenario 2: TOPN lazy materialization query​

This applies to wide-table SELECT * queries on Duplicate tables or Unique Key MOW tables that "sort and then take a small number of rows." When the conditions are met, the query takes the Fetch Row Store path and, combined with the TOPN two-phase optimization, fetches only the rows actually hit.

Trigger conditions​

For the full-row example below, check the following:

  1. The table is a Duplicate table, or a Unique Key MOW table ("enable_unique_key_merge_on_write" = "true").
  2. Enable row store on all columns for this example ("store_row_column" = "true").
  3. The query uses ORDER BY ... LIMIT N, as in the SELECT * example below.
  4. The TOPN lazy materialization optimization must be triggered, and the requested columns must be eligible for row-store fetch. For details, see TOPN Query Optimization.

Table creation example​

CREATE TABLE `tbl_duplicate` (
`k` int(11) NULL,
`v1` string NULL
) ENGINE=OLAP
DUPLICATE KEY(`k`)
COMMENT 'OLAP'
DISTRIBUTED BY HASH(`k`) BUCKETS 1
PROPERTIES (
"light_schema_change" = "true",
"store_row_column" = "true",
"row_store_page_size" = "4096"
);

Note:

This TOPN example uses "store_row_column" = "true" to store all columns. Query eligibility depends on the actual plan, including restrictions on fetching nested subcolumns.

Query example​

SELECT * FROM tbl_duplicate WHERE k < 10 ORDER BY k LIMIT 10;

Verification method​

Run EXPLAIN on the query. Check for lazy materialization and row-store fetch. Plan labels can include FETCH ROW STORE, OPT TWO PHASE, or MaterializeNode, depending on the plan representation.

Configuration parameters​

Set the following parameters in the PROPERTIES of CREATE TABLE:

ParameterDefault in the checked Core 26.1.3 implementationDescription
store_row_columnfalseWhen true, enables row store on all columns.
row_store_columnsAll columns when row store is enabled without a listSelects columns for the row-form copy, such as "col1,col2"; specifying a list enables row store.
row_store_page_size16384 bytes (16 KB)Sets the row-store page size. Explicit values are rounded up to multiples of 4096 bytes.

Use SHOW CREATE TABLE to inspect the resulting definition.

row_store_page_size tuning recommendations​

A smaller page can reduce bytes read for a point lookup but can increase page overhead. A larger page changes that balance. Compare storage size, ingestion throughput, CPU, and query latency on representative data. A value below 4 KB does not produce a smaller effective page because of the 4 KB alignment.

Notes​

  1. Storage overhead: Row store adds data alongside the columnar copy. Measure the increase with your data rather than assuming a fixed storage multiplier.
  2. Page size: Evaluate row_store_page_size for the query pattern; a smaller page is not universally faster.
  3. Changes to existing tables: Core 26.1.3 contains schema-change support for enabling or changing row-store columns on Duplicate Key and Unique Key MOW tables. It rejects disabling an enabled row store with "store_row_column" = "false". Confirm the operation for your Core version and plan for schema-change work before changing a production table.