diff --git a/docs/querying/query-context.md b/docs/querying/query-context.md index 158b59bd044..8c88e8749d4 100644 --- a/docs/querying/query-context.md +++ b/docs/querying/query-context.md @@ -62,6 +62,7 @@ Unless otherwise noted, the following parameters apply to all query types. |secondaryPartitionPruning|`true`|Enable secondary partition pruning on the Broker. The Broker will always prune unnecessary segments from the input scan based on a filter on time intervals, but if the data is further partitioned with hash or range partitioning, this option will enable additional pruning based on a filter on secondary partition dimensions.| |enableJoinLeftTableScanDirect|`false`|This flag applies to queries which have joins. For joins, where left child is a simple scan with a filter, by default, druid will run the scan as a query and the join the results to the right child on broker. Setting this flag to true overrides that behavior and druid will attempt to push the join to data servers instead. Please note that the flag could be applicable to queries even if there is no explicit join. since queries can internally translated into a join by the SQL planner.| |debug| `false` | Flag indicating whether to enable debugging outputs for the query. When set to false, no additional logs will be produced (logs produced will be entirely dependent on your logging level). When set to true, the following addition logs will be produced:
- Log the stack trace of the exception (if any) produced by the query | +|setProcessingThreadNames|`true`| Whether processing thread names will be set to `queryType_dataSource_intervals` while processing a query. This aids in interpreting thread dumps, and is on by default. Query overhead can be reduced slightly by setting this to `false`. This has a tiny effect in most scenarios, but can be meaningful in high-QPS, low-per-segment-processing-time scenarios. | |maxNumericInFilters|`-1`|Max limit for the amount of numeric values that can be compared for a string type dimension when the entire SQL WHERE clause of a query translates only to an [OR](../querying/filters.md#or) of [Bound filter](../querying/filters.md#bound-filter). By default, Druid does not restrict the amount of of numeric Bound Filters on String columns, although this situation may block other queries from running. Set this property to a smaller value to prevent Druid from running queries that have prohibitively long segment processing times. The optimal limit requires some trial and error; we recommend starting with 100. Users who submit a query that exceeds the limit of `maxNumericInFilters` should instead rewrite their queries to use strings in the `WHERE` clause instead of numbers. For example, `WHERE someString IN (‘123’, ‘456’)`. This value cannot exceed the set system configuration `druid.sql.planner.maxNumericInFilters`. This value is ignored if `druid.sql.planner.maxNumericInFilters` is not set explicitly.| |inSubQueryThreshold|`2147483647`| Threshold for minimum number of values in an IN clause to convert the query to a JOIN operation on an inlined table rather than a predicate. A threshold of 0 forces usage of an inline table in all cases; a threshold of [Integer.MAX_VALUE] forces usage of OR in all cases. | diff --git a/processing/src/main/java/org/apache/druid/query/spec/SpecificSegmentQueryRunner.java b/processing/src/main/java/org/apache/druid/query/spec/SpecificSegmentQueryRunner.java index a23eb2ea83f..95217cc6dfc 100644 --- a/processing/src/main/java/org/apache/druid/query/spec/SpecificSegmentQueryRunner.java +++ b/processing/src/main/java/org/apache/druid/query/spec/SpecificSegmentQueryRunner.java @@ -19,6 +19,7 @@ package org.apache.druid.query.spec; +import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Supplier; import org.apache.druid.java.util.common.guava.Accumulator; import org.apache.druid.java.util.common.guava.Sequence; @@ -45,6 +46,9 @@ public class SpecificSegmentQueryRunner implements QueryRunner private final QueryRunner base; private final SpecificSegmentSpec specificSpec; + @VisibleForTesting + static final String CTX_SET_THREAD_NAME = "setProcessingThreadNames"; + public SpecificSegmentQueryRunner( QueryRunner base, SpecificSegmentSpec specificSpec @@ -64,18 +68,26 @@ public class SpecificSegmentQueryRunner implements QueryRunner ) ); + final boolean setName = input.getQuery().getContextBoolean(CTX_SET_THREAD_NAME, true); + final Query query = queryPlus.getQuery(); - final Thread currThread = Thread.currentThread(); - final String currThreadName = currThread.getName(); - final String newName = query.getType() + "_" + query.getDataSource() + "_" + query.getIntervals(); + final Thread currThread = setName ? Thread.currentThread() : null; + final String currThreadName = setName ? currThread.getName() : null; + final String newName = setName ? query.getType() + "_" + query.getDataSource() + "_" + query.getIntervals() : null; - final Sequence baseSequence = doNamed( - currThread, - currThreadName, - newName, - () -> base.run(queryPlus, responseContext) - ); + final Sequence baseSequence; + + if (setName) { + baseSequence = doNamed( + currThread, + currThreadName, + newName, + () -> base.run(queryPlus, responseContext) + ); + } else { + baseSequence = base.run(queryPlus, responseContext); + } Sequence segmentMissingCatchingSequence = new Sequence() { @@ -149,7 +161,11 @@ public class SpecificSegmentQueryRunner implements QueryRunner @Override public RetType wrap(Supplier sequenceProcessing) { - return doNamed(currThread, currThreadName, newName, sequenceProcessing); + if (setName) { + return doNamed(currThread, currThreadName, newName, sequenceProcessing); + } else { + return sequenceProcessing.get(); + } } } ); diff --git a/processing/src/test/java/org/apache/druid/query/spec/SpecificSegmentQueryRunnerTest.java b/processing/src/test/java/org/apache/druid/query/spec/SpecificSegmentQueryRunnerTest.java index 88239b44730..40e2ac296ec 100644 --- a/processing/src/test/java/org/apache/druid/query/spec/SpecificSegmentQueryRunnerTest.java +++ b/processing/src/test/java/org/apache/druid/query/spec/SpecificSegmentQueryRunnerTest.java @@ -21,6 +21,7 @@ package org.apache.druid.query.spec; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; import org.apache.druid.jackson.DefaultObjectMapper; import org.apache.druid.java.util.common.DateTimes; import org.apache.druid.java.util.common.Intervals; @@ -181,6 +182,8 @@ public class SpecificSegmentQueryRunnerTest new CountAggregatorFactory("rows") ) ) + // Do one test with CTX_SET_THREAD_NAME = false. + .context(ImmutableMap.of(SpecificSegmentQueryRunner.CTX_SET_THREAD_NAME, false)) .build(); Sequence results = queryRunner.run(QueryPlus.wrap(query), responseContext); List> res = results.toList(); diff --git a/website/.spelling b/website/.spelling index d8d4cb0f8a8..9d00a3771b6 100644 --- a/website/.spelling +++ b/website/.spelling @@ -285,6 +285,7 @@ gzipped hadoop hasher hashtable +high-QPS historicals hostname hostnames @@ -377,6 +378,7 @@ procs programmatically proto proxied +QPS quantile quantiles queryable @@ -403,6 +405,7 @@ searchable secondaryPartitionPruning seekable-stream servlet +setProcessingThreadNames simple-client-sslcontext sharded sharding