All Products
Search
Document Center

E-MapReduce:Data cache for data lakes

Last Updated:Mar 24, 2026

This topic describes the operation, caching mechanisms, and configuration of Data Cache for data lakes. By caching hot data from external storage (such as HDFS and object storage) on local BE nodes, Data Cache significantly reduces redundant I/O overhead and improves query performance for data lake workloads.

Overview

In data lake analytics, StarRocks acts as an OLAP query engine that frequently scans data files on HDFS or object storage. For scenarios that repeatedly access the same data, such as ad-hoc queries, extensive remote I/O can become a performance bottleneck.

Available since v2.5, the Data Cache feature caches raw data from external storage on local BE nodes by splitting it into blocks. This approach avoids redundant data fetching from remote sources and accelerates query and analytics performance for hot data.

Note

Data Cache applies only to queries against external storage using external tables (excluding JDBC external tables) or External Catalogs. It does not apply to queries on StarRocks native tables. Since v3.4.0, tables in storage-compute separation mode and data lake queries share the same Data Cache instance. If you are using v3.4.0 or a later version, see the Data Cache for storage-compute separation documentation for configuration details.

Limitations

  • Data Cache for data lakes is supported in StarRocks v2.5 and later, and is enabled by default starting from v3.3.0.

  • It applies only to queries on external tables and External Catalogs, not to queries on native tables.

  • It supports External Catalog types that use the StarRocks Native File Reader (such as Hive, Iceberg, Hudi, Delta Lake, and Paimon). It does not support catalogs that access data via JNI (such as JDBC Catalog).

Note

Some catalogs automatically select the data access method based on certain conditions. For example, a Paimon Catalog might automatically switch to JNI access depending on the data compaction status. In such cases, Data Cache is not used.

Cache media

StarRocks uses the memory and disks of BE/CN nodes as cache media and supports the following caching modes:

  • Memory-only cache: Offers the fastest caching speed but is limited by memory capacity.

  • Two-tier cache (memory + disk): Expands cache capacity, balancing performance and cost.

Note

When you use disks as the cache media, caching performance depends directly on disk performance. We recommend using a high-performance cloud disk (such as ESSD PL1). If disk performance is moderate, you can add multiple disks to distribute the I/O load.

Cache eviction mechanism

The memory and disk tiers of Data Cache evict data independently. In a two-tier (memory and disk) cache, the mechanism works as follows:

  • The system first attempts to read data from memory. If a cache miss occurs in memory, it reads from disk and then tries to load the data into memory.

  • Data evicted from memory is written to disk. Data evicted from disk is discarded.

StarRocks Data Cache supports two eviction policies: LRU and SLRU (Segmented LRU). SLRU is the default policy.

Note

The SLRU policy requires StarRocks v3.4 or later.

SLRU divides the cache space into an eviction segment and a probationary segment, both of which use an LRU policy. When data is first accessed, it enters the eviction segment. If data in the eviction segment is accessed again, it is promoted to the probationary segment. Data evicted from the probationary segment is moved back to the eviction segment. Data evicted from the eviction segment is removed from the cache. Compared to LRU, SLRU is more resistant to sudden, sparse traffic and protects frequently accessed data from being evicted by a single large-scale query.

Enable and disable Data Cache

Data Cache for data lakes is controlled by the system variable enable_scan_datacache and the BE parameter datacache_enable. It is enabled by default starting from v3.3.0. You can query its current status with the following SQL statement:

SHOW VARIABLES LIKE 'enable_scan_datacache';

The main configuration parameters are as follows:

Parameter

Type

Default

Description

datacache_enable

BE parameter

true

Specifies whether to enable Data Cache.

enable_scan_datacache

System variable

true

Specifies whether to use Data Cache to accelerate queries.

datacache_mem_size

BE parameter

0

The maximum memory cache size. We recommend setting this to 10% to 20% of the total memory.

datacache_disk_size

BE parameter

0

The maximum disk cache size for a single disk. You can set this as a percentage (e.g., 80%) or an absolute value (e.g., 2T, 500G).

datacache_auto_adjust_enable

BE parameter

true

Specifies whether to automatically adjust the disk capacity for Data Cache. When enabled, the cache capacity is dynamically adjusted based on current disk usage. Even if datacache_disk_size is 0, the system automatically allocates cache space based on disk usage.

To disable Data Cache, run the following command:

SET GLOBAL enable_scan_datacache = false;

Cache population rules

Since v3.3.2, to improve the cache hit rate, StarRocks uses the following rules to determine whether to populate the Data Cache:

  • Non-SELECT queries (such as ANALYZE TABLE and INSERT INTO SELECT) do not populate the cache.

  • Queries that scan all partitions of a table do not populate the cache (unless the table has only a single partition).

  • Queries that scan all columns of a table do not populate the cache (unless the table has only a single column).

  • Queries on tables other than Hive, Paimon, Delta Lake, Hudi, or Iceberg do not populate the cache.

You can use EXPLAIN VERBOSE to check if a query triggers cache population:

EXPLAIN VERBOSE SELECT col1 FROM hudi_table;

In the query plan, dataCacheOptions={populate: false} indicates that the query will not populate the cache. To force cache population, set the following variable:

SET populate_datacache_mode = 'always';

I/O adaptiveness

When the I/O load on the cache disk is too high, the I/O adaptiveness feature of Data Cache automatically routes some cache requests to remote storage. This approach uses both the local cache and remote storage to increase I/O throughput and prevent significant long-tail disk latency. This feature is enabled by default. To enable it manually, run the following command:

SET GLOBAL enable_datacache_io_adaptor = true;

Monitor Data Cache

The information_schema.be_datacache_metrics view shows the capacity and usage of the memory and disk cache on each BE node:

SELECT * FROM information_schema.be_datacache_metrics;

Field

Description

BE_ID

The ID of the BE node.

STATUS

The status of the BE node. Normal indicates a healthy status.

DISK_QUOTA_BYTES

The configured disk cache capacity, in bytes.

DISK_USED_BYTES

The current disk cache usage, in bytes.

MEM_QUOTA_BYTES

The configured memory cache capacity, in bytes.

MEM_USED_BYTES

The current memory cache usage, in bytes.

META_USED_BYTES

The memory space occupied by system metadata, in bytes.

DIR_SPACES

The cache paths on disk and the cache size for each path.

Monitor SQL cache hits

You can monitor the following metrics in a query profile to evaluate the performance of Data Cache for a given query:

Metric

Description

DataCacheReadBytes

The amount of data read from the memory and disk cache.

DataCacheWriteBytes

The amount of data loaded from external storage into the memory and disk cache.

BytesRead

The total amount of data read, including from memory, disk, and external storage.