TDengine Built-in Read Cache: Faster Latest-Data Queries Without Redis

Juno Qiu

July 7, 2026 /

In IoT and industrial IoT systems, the newest data point is often the one that matters most. Dashboards, alerting rules, and operator workflows all depend on retrieving the latest readings quickly and consistently.

Limitations of traditional caching approaches

External caches such as Redis can improve read speed, but they also add another system to deploy, monitor, and keep consistent with the database. For latest-value queries, that extra layer is often unnecessary.

The built-in read cache approach

TDengine embeds this cache inside the database engine. It keeps the latest record for each table in memory and manages the cached data automatically. The result is simpler deployment, less maintenance work, and stronger consistency than a separate cache layer can usually provide.

Cache mode details

The cachemodel parameter supports four modes:

  1. none: No caching. For scenarios with no performance demands on latest-data queries.
  2. last_row: Caches the most recent complete row per subtable, optimizing the LAST_ROW function.
  3. last_value: Caches each column’s most recent non-NULL value per subtable, optimizing the LAST function.
  4. both: Caches both row and column data simultaneously.

Cache size configuration

The cachesize parameter controls memory per vnode. Default is 1 MB, range [1, 65536] MB. Considerations include subtable count, row data width, and available memory.

Performance test: 8x improvement backed by data

Test scenario: smart meter data. 1 billion records across 10,000 devices, 10,000 records per device.

Query typeNo cacheBoth modeImprovement
LAST query353 ms44 ms~8x
LAST_ROW query344 ms46 ms~7.5x

Configuration command: ALTER DATABASE power CACHEMODEL 'both';

Application scenarios

Real-time monitoring dashboards. Dashboards displaying the latest status of thousands of devices require sub-100 ms query response times to maintain visual refresh rates.

Equipment anomaly detection. Anomaly detection logic frequently retrieves the most recent current values for comparison against threshold baselines. The cache eliminates repeated disk reads.

Real-time reports and dashboards. Reports aggregating the latest operating parameters across production lines need fast access to the most recent data point for each metric.

Configuration recommendations

Choose cache modes based on business needs. If the application only uses LAST_ROW queries, the last_row mode is sufficient. For environments with ample memory and demanding latest-data query requirements, increase the cachesize parameter accordingly.

Summary

TDengine’s built-in read cache is a practical optimization for latest-data queries in IoT and industrial IoT systems. It can deliver millisecond-level responses without adding Redis or another external cache to the architecture.