---
title: Manage the Last Value Cache
description: The InfluxDB 3 Enterprise Last Value Cache (LVC) lets you cache the most recent values for specific fields in a table, improving the performance of queries that return the most recent value of a field for specific time series or the last N values of a field.
url: https://docs.influxdata.com/influxdb3/enterprise/admin/last-value-cache/
estimated_tokens: 2122
product: InfluxDB 3 Enterprise
version: enterprise
publisher: InfluxData
canonical: https://docs.influxdata.com/influxdb3/enterprise/admin/last-value-cache/
date: '2025-08-29T08:44:59-06:00'
lastmod: '2025-08-29T08:44:59-06:00'
---

The InfluxDB 3 Enterprise Last Value Cache (LVC) lets you cache the most recent
values for specific fields in a table, improving the performance of queries that
return the most recent value of a field for specific series or the last N values
of a field.

The LVC is an in-memory cache that stores the last N number of values for
specific fields of series in a table. When you create an LVC, you can specify
what fields to cache, what tags to use to identify each series, and the
number of values to cache for each unique series.
An LVC is associated with a table, which can have multiple LVCs.

* [Create a Last Value Cache](#create-a-last-value-cache)
* [Query a Last Value Cache](#query-a-last-value-cache)
* [Show information about Last Value Caches](#show-information-about-last-value-caches)
* [Delete a Last Value Cache](#delete-a-last-value-cache)

* [Important things to know about the Last Value Cache](#important-things-to-know-about-the-last-value-cache)
  * [High cardinality key columns](#high-cardinality-key-columns)

  * [Value count](#value-count)

  * [Defining value columns](#defining-value-columns)

Consider a dataset with the following schema (similar to the[home sensor sample dataset](/influxdb3/enterprise/reference/sample-data/#home-sensor-data)):

* home (table)
  * tags:
    * room
      * kitchen
      * living room

    * wall
      * north
      * east
      * south

  * fields:
    * co (integer)
    * temp (float)
    * hum (float)

If you cache the last value for each field per room and wall, the LVC looks
similar to this:

|   room    |wall |co |hum |temp|        time        |
|-----------|-----|---|----|----|--------------------|
|  Kitchen  |east |26 |36.5|22.7|2022-01-01T20:00:00Z|
|Living Room|north|17 |36.4|22.2|2022-01-01T20:00:00Z|
|Living Room|south|16 |36.3|22.1|2022-01-01T20:00:00Z|

If you cache the last four values of each field per room and wall, the LVC looks
similar to the following:

|   room    |wall |co |hum |temp|        time        |
|-----------|-----|---|----|----|--------------------|
|  Kitchen  |east |26 |36.5|22.7|2022-01-01T20:00:00Z|
|  Kitchen  |east | 9 |36.0|22.7|2022-01-01T17:00:00Z|
|  Kitchen  |east | 3 |36.2|22.7|2022-01-01T15:00:00Z|
|  Kitchen  |east | 0 |36.1|22.7|2022-01-01T10:00:00Z|
|Living Room|north|17 |36.4|22.2|2022-01-01T20:00:00Z|
|Living Room|north| 5 |35.9|22.6|2022-01-01T17:00:00Z|
|Living Room|north| 1 |36.1|22.3|2022-01-01T15:00:00Z|
|Living Room|north| 0 |36.0|21.8|2022-01-01T10:00:00Z|
|Living Room|south|16 |36.3|22.1|2022-01-01T20:00:00Z|
|Living Room|south| 4 |35.8|22.5|2022-01-01T17:00:00Z|
|Living Room|south| 0 |36.0|22.3|2022-01-01T15:00:00Z|
|Living Room|south| 0 |35.9|21.8|2022-01-01T10:00:00Z|

#### Null column values

*Null* column values are still considered values and are cached in the LVC.
If you write data to a table and don’t provide a value for an existing column,
the column value is cached as *null*.

## [Create a Last Value Cache](/influxdb3/enterprise/admin/last-value-cache/create/)

Use the [`influxdb3 create last_cache` command](/influxdb3/enterprise/reference/cli/influxdb3/create/last_cache/)to create a Last Value Cache.

```bash
influxdb3 create last_cache \
  --database example-db \
  --token 00xoXX0xXXx0000XxxxXx0Xx0xx0 \
  --table home \
  --node-spec "nodes:node-01,node-02" \
  --key-columns room,wall \
  --value-columns temp,hum,co \
  --count 5 \
  --ttl 30mins \
  homeLastCache
```

## [Query a Last Value Cache](/influxdb3/enterprise/admin/last-value-cache/query/)

Use the [`last_cache()` SQL function](/influxdb3/enterprise/reference/sql/functions/cache/#last_cache)in the `FROM` clause of an SQL `SELECT` statement to query data from the
Last Value Cache.

```sql
SELECT * FROM last_cache('table-name', 'cache-name')
```

> [!Important]
> You must use SQL to query the LVC.
> InfluxQL does not support the `last_cache()` function.

## [Show information about Last Value Caches](/influxdb3/enterprise/admin/last-value-cache/show/)

Use the `influxdb3 show system table` command to query and output Last Value
Cache information from the `last_caches` system table.

```bash
influxdb3 show system \
  --database example-db \
  --token 00xoXX0xXXx0000XxxxXx0Xx0xx0 \
  table last_caches
```

## [Delete a Last Value Cache](/influxdb3/enterprise/admin/last-value-cache/delete/)

Use the [`influxdb3 delete last_cache` command](/influxdb3/enterprise/reference/cli/influxdb3/delete/last_cache/)to delete a Last Value Cache.

```bash
influxdb3 delete last_cache \
  --database example-db \
  --token 00xoXX0xXXx0000XxxxXx0Xx0xx0 \
  --table home \
  homeLastCache
```

## Important things to know about the Last Value Cache

LVCs are stored in memory; the larger the cache, the more memory your InfluxDB 3 node requires to
maintain it. Consider the following:

* [Cache data loading](#cache-data-loading)
* [High cardinality key columns](#high-cardinality-key-columns)
* [Value count](#value-count)

## Cache data loading

On cache creation, InfluxDB 3 Enterprise loads historical data into the cache.
On restart, the server automatically reloads cache data.

### High cardinality key columns

“Cardinality” refers to the number of unique key column combinations in your
cached data. While the InfluxDB 3 storage engine is not limited by cardinality,
it does affect the LVC. Higher cardinality increases memory requirements for
storing the LVC and can affect LVC query performance. We recommend the
following:

* Only use tags important to your query workload as key columns in the LVC.
  Caching unnecessary tags or fields as key columns results in higher
  cardinality without any benefit.
* Avoid including high-cardinality key columns in your LVC.
* Don’t include multiple high-cardinality key columns in your LVC.

To estimate total key column cardinality in an LVC, use the
following equation:

```txt
num_uniq_col_val_N [× num_uniq_col_val_N …] = key_column_cardinality
```

### Value count

By increasing the number of values to store in the LVC, you increase the number
of rows stored in the cache and the amount of memory required to store them. Be
judicious with the number of values to store. This count is per unique key
column combination. If you include two tags as key columns, one with three
unique values and the other with 10, you could have up to 30 unique key column
combinations. If you want to keep the last 10 values, you could potentially
have 300+ rows in the cache.

To get an idea of the number of rows required to cache the specified number of
values, use the following equation:

```txt
key_column_cardinality × count = number_of_rows
```

### Defining value columns

When creating an LVC, if you include the `--value-columns` options to specify
which fields to cache as value columns, any new fields added in the future will
not be added to the cache.

However, if you omit the `--value-columns` option, all columns other than those
specified as `--key-columns` are cached as value columns, including columns that
are added later.

#### Related

* [last\_cache SQL function](/influxdb3/enterprise/reference/sql/functions/cache/#last_cache)
* [Manage Last Value Caches with InfluxDB 3 Explorer](/influxdb3/explorer/manage-caches/last-value-caches/)

[cache](/influxdb3/enterprise/tags/cache/)
| room | wall | co | hum | temp | time |
| --- | --- | --- | --- | --- | --- |
| room | wall | co | hum | temp | time |
| Kitchen | east | 26 | 36.5 | 22.7 | 2022-01-01T20:00:00Z |
| Living Room | north | 17 | 36.4 | 22.2 | 2022-01-01T20:00:00Z |
| Living Room | south | 16 | 36.3 | 22.1 | 2022-01-01T20:00:00Z |

| room | wall | co | hum | temp | time |
| --- | --- | --- | --- | --- | --- |
| room | wall | co | hum | temp | time |
| Kitchen | east | 26 | 36.5 | 22.7 | 2022-01-01T20:00:00Z |
| Kitchen | east | 9 | 36.0 | 22.7 | 2022-01-01T17:00:00Z |
| Kitchen | east | 3 | 36.2 | 22.7 | 2022-01-01T15:00:00Z |
| Kitchen | east | 0 | 36.1 | 22.7 | 2022-01-01T10:00:00Z |
| Living Room | north | 17 | 36.4 | 22.2 | 2022-01-01T20:00:00Z |
| Living Room | north | 5 | 35.9 | 22.6 | 2022-01-01T17:00:00Z |
| Living Room | north | 1 | 36.1 | 22.3 | 2022-01-01T15:00:00Z |
| Living Room | north | 0 | 36.0 | 21.8 | 2022-01-01T10:00:00Z |
| Living Room | south | 16 | 36.3 | 22.1 | 2022-01-01T20:00:00Z |
| Living Room | south | 4 | 35.8 | 22.5 | 2022-01-01T17:00:00Z |
| Living Room | south | 0 | 36.0 | 22.3 | 2022-01-01T15:00:00Z |
| Living Room | south | 0 | 35.9 | 21.8 | 2022-01-01T10:00:00Z |
