Skip to content

Commit a60f081

Browse files
update: add info on distinct values cache
1 parent 97653f8 commit a60f081

File tree

2 files changed

+113
-4
lines changed

2 files changed

+113
-4
lines changed

content/shared/v3-core-get-started/_index.md

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -654,10 +654,64 @@ influxdb3 delete last_cache \
654654
655655
### Distinct values cache
656656
657-
Similar to the Last values cache, the database can cache in RAM the distinct values for a single column in a table or a hierarchy of columns. This is useful for fast metadata lookups, which can return in under 30 milliseconds. Many of the options are similar to the last value cache. See the CLI output for more information:
657+
Similar to the Last values cache, the database can cache in RAM the distinct values for a single column in a table or a hierarchy of columns. This is useful for fast metadata lookups, which can return in under 30 milliseconds. Many of the options are similar to the last value cache.
658+
659+
You can use the `influxdb3` CLI to [create a distinct values cache](/influxdb3/version/reference/cli/influxdb3/create/distinct_cache/).
658660
659661
```bash
660-
influxdb3 create distinct_cache -h
662+
influxdb3 create distinct_cache \
663+
-d <DATABASE_NAME> \
664+
-t <TABLE> \
665+
--columns <COLUMNS> \
666+
[CACHE_NAME]
667+
```
668+
669+
Consider the following `cpu` sample table:
670+
671+
| host | application | time | usage\_percent | status |
672+
| ----- | ----- | ----- | ----- | ----- |
673+
| Bravo | database | 2024-12-11T10:00:00 | 55.2 | OK |
674+
| Charlie | cache | 2024-12-11T10:00:00 | 65.4 | OK |
675+
| Bravo | database | 2024-12-11T10:01:00 | 70.1 | Warn |
676+
| Bravo | database | 2024-12-11T10:01:00 | 80.5 | OK |
677+
| Alpha | webserver | 2024-12-11T10:02:00 | 25.3 | Warn |
678+
679+
The following command creates a distinct values cache named `cpuDistinctCache`:
680+
681+
```bash
682+
influxdb3 create distinct_cache \
683+
--database=servers \
684+
--table=cpu \
685+
--columns=host,application \
686+
cpuDistinctCache
687+
```
688+
689+
#### Query a distinct values cache
690+
691+
To use the distinct values cache, call it using the `distinct_cache()` function in your query--for example:
692+
693+
```bash
694+
influxdb3 query \
695+
--database=servers \
696+
"SELECT * FROM distinct_cache('cpu', 'cpuDistinctCache')"
697+
```
698+
699+
> [!Note]
700+
> #### Only works with SQL
701+
>
702+
> The Distinct cache only works with SQL, not InfluxQL; SQL is the default language.
703+
704+
705+
706+
#### Delete a distinct values cache
707+
708+
Use the `influxdb3` CLI to [delete a distinct values cache](/influxdb3/version/reference/cli/influxdb3/delete/distinct_cache/)
709+
710+
```bash
711+
influxdb3 delete distinct_cache \
712+
-d <DATABASE_NAME> \
713+
-t <TABLE> \
714+
--cache-name <CACHE_NAME>
661715
```
662716
663717
### Python plugins and the Processing engine

content/shared/v3-enterprise-get-started/_index.md

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -647,12 +647,67 @@ influxdb3 delete last_cache \
647647
648648
### Distinct values cache
649649
650-
Similar to the Last values cache, the database can cache in RAM the distinct values for a single column in a table or a heirarchy of columns. This is useful for fast metadata lookups, which can return in under 30 milliseconds. Many of the options are similar to the last value cache. See the CLI output for more information:
650+
Similar to the Last values cache, the database can cache in RAM the distinct values for a single column in a table or a hierarchy of columns. This is useful for fast metadata lookups, which can return in under 30 milliseconds. Many of the options are similar to the last value cache.
651+
652+
You can use the `influxdb3` CLI to [create a distinct values cache](/influxdb3/version/reference/cli/influxdb3/create/distinct_cache/).
653+
654+
```bash
655+
influxdb3 create distinct_cache \
656+
-d <DATABASE_NAME> \
657+
-t <TABLE> \
658+
--columns <COLUMNS> \
659+
[CACHE_NAME]
660+
```
661+
662+
Consider the following `cpu` sample table:
663+
664+
| host | application | time | usage\_percent | status |
665+
| ----- | ----- | ----- | ----- | ----- |
666+
| Bravo | database | 2024-12-11T10:00:00 | 55.2 | OK |
667+
| Charlie | cache | 2024-12-11T10:00:00 | 65.4 | OK |
668+
| Bravo | database | 2024-12-11T10:01:00 | 70.1 | Warn |
669+
| Bravo | database | 2024-12-11T10:01:00 | 80.5 | OK |
670+
| Alpha | webserver | 2024-12-11T10:02:00 | 25.3 | Warn |
671+
672+
The following command creates a distinct values cache named `cpuDistinctCache`:
673+
674+
```bash
675+
influxdb3 create distinct_cache \
676+
--database=servers \
677+
--table=cpu \
678+
--columns=host,application \
679+
cpuDistinctCache
680+
```
681+
682+
#### Query a distinct values cache
683+
684+
To use the distinct values cache, call it using the `distinct_cache()` function in your query--for example:
651685
652686
```bash
653-
influxdb3 create distinct_cache -h
687+
influxdb3 query \
688+
--database=servers \
689+
"SELECT * FROM distinct_cache('cpu', 'cpuDistinctCache')"
654690
```
655691
692+
> [!Note]
693+
> #### Only works with SQL
694+
>
695+
> The Distinct values cache only works with SQL, not InfluxQL; SQL is the default language.
696+
697+
698+
699+
#### Delete a distinct values cache
700+
701+
Use the `influxdb3` CLI to [delete a distinct values cache](/influxdb3/version/reference/cli/influxdb3/delete/distinct_cache/)
702+
703+
```bash
704+
influxdb3 delete distinct_cache \
705+
-d <DATABASE_NAME> \
706+
-t <TABLE> \
707+
--cache-name <CACHE_NAME>
708+
```
709+
710+
656711
### Python plugins and the Processing engine
657712
658713
The InfluxDB 3 Processing engine is an embedded Python VM for running code inside the database to process and transform data.

0 commit comments

Comments
 (0)