---
title: Manage the Distinct Value Cache
description: The InfluxDB 3 Enterprise Distinct Value Cache (DVC) lets you cache distinct values of one or more columns in a table, improving the performance of queries that return distinct tag and field values.
url: https://docs.influxdata.com/influxdb3/enterprise/admin/distinct-value-cache/
estimated_tokens: 2473
product: InfluxDB 3 Enterprise
version: enterprise
---

# Manage the Distinct Value Cache

The InfluxDB 3 Enterprise Distinct Value Cache (DVC) lets you cache distinct values of one or more columns in a table, improving the performance of queries that return distinct tag and field values.

The DVC is an in-memory cache that stores distinct values for specific columns in a table. When you create a DVC, you can specify what columns’ distinct values to cache, the maximum number of distinct value combinations to cache, and the maximum age of cached values. A DVC is associated with a table, which can have multiple DVCs.

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

-   [Important things to know about the Distinct Value Cache](#important-things-to-know-about-the-distinct-value-cache)
    -   [High cardinality limits](#high-cardinality-limits)

Consider a dataset with the following schema:

-   wind\_data (table)
    -   tags:
        -   country
            -   *multiple European countries*
        -   county
            -   *multiple European counties*
        -   city
            -   *multiple European cities*
    -   fields:
        -   wind\_speed (float)
        -   wind\_direction (integer)

If you cache distinct values for `country`, `county`, and `city`, the DVC looks similar to this:

| country | county | city |
| --- | --- | --- |
| Austria | Salzburg | Salzburg |
| Austria | Vienna | Vienna |
| Belgium | Antwerp | Antwerp |
| Belgium | West Flanders | Bruges |
| Czech Republic | Liberec Region | Liberec |
| Czech Republic | Prague | Prague |
| Denmark | Capital Region | Copenhagen |
| Denmark | Southern Denmark | Odense |
| Estonia | Ida-Viru County | Kohtla-Järve |
| Estonia | Ida-Viru County | Narva |
| … | … | … |

#### Repeated values in DVC results

Distinct values may appear multiple times in a column when querying the DVC, but only when associated with distinct values in other columns. If you query a single column in the DVC, no values are repeated in the results.

#### Null column values

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

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

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

```bash
influxdb3 create distinct_cache \
  --database example-db \
  --token 00xoXX0xXXx0000XxxxXx0Xx0xx0 \
  --table home \
  --node-spec "nodes:node-01,node-02" \
  --columns country,county,city \
  --max-cardinality 10000 \
  --max-age 24h \
  windDistinctCache
```

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

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

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

You must use SQL to query the DVC. InfluxQL does not support the `distinct_cache()` function.

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

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

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

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

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

```bash
influxdb3 delete distinct_cache \
  --database example-db \
  --token 00xoXX0xXXx0000XxxxXx0Xx0xx0 \
  --table wind_data \
  windDistinctCache
```

## Important things to know about the Distinct Value Cache

DVCs 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 limits](#high-cardinality-limits)

## 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 limits

“Cardinality” refers to the number of unique key column combinations in your cached data and essentially defines the maximum number of rows to store in your DVC. While the InfluxDB 3 storage engine is not limited by cardinality, it does affect the DVC. You can define a custom maximum cardinality limit for a DVC, but higher cardinality increases memory requirements for storing the DVC and can affect DVC query performance.

#### Related

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

[cache](/influxdb3/enterprise/tags/cache/)
