Skip to content

Commit 21e65dc

Browse files
committed
indexdb
1 parent 51b5579 commit 21e65dc

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

victoriametrics/indexdb.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# IndexDB
2+
3+
Source: <https://victoriametrics.com/blog/vmstorage-how-indexdb-works/>
4+
5+
VictoriaMetrics identifies time series by `TSID` (time series ID) and stores raw samples sorted by `TSID`. Thus, the TSID is a primary index and could be used for searching and retrieving raw samples. However, the TSID is never exposed to the clients, i.e. it is for internal use only.
6+
7+
Instead, VictoriaMetrics maintains an **inverted index** that enables searching the raw samples by metric name, label name, and label value by mapping these values to the corresponding TSIDs.
8+
9+
VictoriaMetrics uses two types of inverted indexes:
10+
11+
- Global index. Searches using this index is performed across the entire retention period.
12+
- Per-day index. This index stores mappings similar to ones in global index but also includes the date in each mapping. This speeds up data retrieval for queries within a shorter time range (which is often just the last day).
13+
14+
Mappings are added to the indexes during the data ingestion:
15+
16+
- In global index each mapping is created only once per retention period.
17+
- In the per-day index each mapping is created for each unique date that has been seen in the samples for the corresponding time series.
18+
19+
When the search query is executed, VictoriaMetrics decides which index to use based on the time range of the query:
20+
21+
- Per-day index is used if the search time range is 40 days or less.
22+
- Global index is used for search queries with a time range greater than 40 days.
23+
24+
Mappings are added to the indexes during the data ingestion:
25+
26+
- In global index each mapping is created only once per retention period.
27+
- In the per-day index each mapping is created for each unique date that has been seen in the samples for the corresponding time series.
28+
29+
IndexDB respects retention period and once it is over, the indexes are dropped. For the new retention period, the indexes are gradually populated again as the new samples arrive.

0 commit comments

Comments
 (0)