Skip to content

Commit 6117a0d

Browse files
authored
Change index.mapping.use_doc_values_skipper default setting to true (#134221)
TSBD and LogsDB indexes with this setting set to true do not use backing indexes for `host.name`, `_tsid` or `@timestamp` fields, and instead enable sparse indexes on their doc_values fields. This was originally added and set to default to `true` a while back, but was then changed to default to `false` when performance suffered. Changes to lucene, and the addition of filter-by-filter optimizations on skipper queries, means that performance looks more acceptable now. This is still gated behind a feature flag so that we can measure the behaviour in nightly benchmarks before enabling for public use.
1 parent 188e6cd commit 6117a0d

File tree

5 files changed

+6
-6
lines changed

5 files changed

+6
-6
lines changed

server/src/main/java/org/elasticsearch/index/IndexSettings.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ public boolean isES87TSDBCodecEnabled() {
671671
public static final boolean DOC_VALUES_SKIPPER = new FeatureFlag("doc_values_skipper").isEnabled();
672672
public static final Setting<Boolean> USE_DOC_VALUES_SKIPPER = Setting.boolSetting(
673673
"index.mapping.use_doc_values_skipper",
674-
false,
674+
true,
675675
Property.IndexScope,
676676
Property.Final
677677
);

server/src/main/java/org/elasticsearch/index/IndexVersions.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ private static Version parseUnchecked(String version) {
191191
public static final IndexVersion UPGRADE_TO_LUCENE_10_3_1 = def(9_041_0_00, Version.LUCENE_10_3_1);
192192

193193
public static final IndexVersion REENABLED_TIMESTAMP_DOC_VALUES_SPARSE_INDEX = def(9_042_0_00, Version.LUCENE_10_3_1);
194+
public static final IndexVersion SKIPPERS_ENABLED_BY_DEFAULT = def(9_043_0_00, Version.LUCENE_10_3_1);
194195

195196
/*
196197
* STOP! READ THIS FIRST! No, really,

server/src/main/java/org/elasticsearch/index/mapper/DateFieldMapper.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,7 +1100,7 @@ private DateFieldMapper(
11001100
* Determines whether the doc values skipper (sparse index) should be used for the {@code @timestamp} field.
11011101
* <p>
11021102
* The doc values skipper is enabled only if {@code index.mapping.use_doc_values_skipper} is set to {@code true},
1103-
* the index was created on or after {@link IndexVersions#REENABLED_TIMESTAMP_DOC_VALUES_SPARSE_INDEX}, and the
1103+
* the index was created on or after {@link IndexVersions#SKIPPERS_ENABLED_BY_DEFAULT}, and the
11041104
* field has doc values enabled. Additionally, the index mode must be {@link IndexMode#LOGSDB} or {@link IndexMode#TIME_SERIES}, and
11051105
* the index sorting configuration must include the {@code @timestamp} field.
11061106
*
@@ -1109,9 +1109,8 @@ private DateFieldMapper(
11091109
* @param fullFieldName The full name of the field being checked, expected to be {@code @timestamp}.
11101110
* @return {@code true} if the doc values skipper should be used, {@code false} otherwise.
11111111
*/
1112-
11131112
private static boolean shouldUseDocValuesSkipper(IndexSettings indexSettings, boolean hasDocValues, final String fullFieldName) {
1114-
return indexSettings.getIndexVersionCreated().onOrAfter(IndexVersions.REENABLED_TIMESTAMP_DOC_VALUES_SPARSE_INDEX)
1113+
return indexSettings.getIndexVersionCreated().onOrAfter(IndexVersions.SKIPPERS_ENABLED_BY_DEFAULT)
11151114
&& indexSettings.useDocValuesSkipper()
11161115
&& hasDocValues
11171116
&& (IndexMode.LOGSDB.equals(indexSettings.getMode()) || IndexMode.TIME_SERIES.equals(indexSettings.getMode()))

server/src/main/java/org/elasticsearch/index/mapper/KeywordFieldMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ private static FieldType resolveFieldType(
515515
assert hasDocValues.getValue();
516516
return new FieldType(Defaults.FIELD_TYPE_WITH_SKIP_DOC_VALUES);
517517
}
518-
if (indexCreatedVersion.onOrAfter(IndexVersions.HOSTNAME_DOC_VALUES_SPARSE_INDEX)
518+
if (indexCreatedVersion.onOrAfter(IndexVersions.SKIPPERS_ENABLED_BY_DEFAULT)
519519
&& shouldUseDocValuesSkipper(hasDocValues.getValue(), indexSortConfig, indexMode, fullFieldName)) {
520520
return new FieldType(Defaults.FIELD_TYPE_WITH_SKIP_DOC_VALUES);
521521
}

server/src/main/java/org/elasticsearch/index/mapper/TimeSeriesIdFieldMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public static TimeSeriesIdFieldMapper getInstance(boolean useDocValuesSkipper) {
6060
}
6161

6262
public static TimeSeriesIdFieldMapper getInstance(MappingParserContext context) {
63-
boolean useDocValuesSkipper = context.indexVersionCreated().onOrAfter(IndexVersions.TIME_SERIES_ID_DOC_VALUES_SPARSE_INDEX)
63+
boolean useDocValuesSkipper = context.indexVersionCreated().onOrAfter(IndexVersions.SKIPPERS_ENABLED_BY_DEFAULT)
6464
&& context.getIndexSettings().useDocValuesSkipper();
6565
return TimeSeriesIdFieldMapper.getInstance(useDocValuesSkipper);
6666
}

0 commit comments

Comments
 (0)