Skip to content

Optimize segment merging in the tsdb doc value codec #126111

@martijnvg

Description

@martijnvg

The doc values codec iterates a few times over the doc value instance that needs to be written to disk. In case when merging and index sorting is enabled, this is much more expensive, as each time the doc values instance is iterated a merge sort is performed (in order to get the doc ids from different segments in order of index sorting).

There are several reasons why the doc value instance is iterated multiple times:

  • To compute stats (num values, number of docs with value) required for writing values to disk.
  • To write bitset that indicate which documents have a value. (indexed disi, jump table)
  • To write the actual values to disk.
  • To write the addresses to disk (in case docs have multiple values)

This applies for numeric doc values, but also for the ordinals of sorted (set) doc values.

The following changes should be made to address this performance issue:

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions