HomeGetting StartedInstallation & SetupDevelopment & IntegrationDeployment & OperationsData ManagementTechnical SupportPlatform Updates
DocsData ManagementQueryingquery hints

Query Hints

This page contains all query hints available in Stardog

<details open markdown="block"> <summary> Page Contents </summary> 1. TOC </details>

General Query Optimization Hints

These hints are suggestions to Stardog’s query optimizer. They can impact the query plan selected by the optimizer but they should not change query results.

Hint NamePossible ValuesPositionDescription
equality.identitycomma, separated list of variables (e.g. ?o,?o2)scopeEnumerates variables for which equality (i.e. ==) should be treated as identity (i.e. sameTerm in SPARQL). See Managing Query Performance - equality.identity for more information.
group.joins-scopeEnables grouping of graph patterns for join order optimization: all patterns in the group will be joined together before joining with other patterns. See Managing Query Performance - group.joins for more information.
push.filtersdefault, aggressive, or offscopeSpecifies how the optimizer tries to push filters down the query plan: <br><br> - aggressive: every filter will be pushed as deep down as possible <br><br> - default: the optimizer will decide how deep to push based on other factors, e.g. estimated cardinality <br><br> - off: the optimization is off. <br><br> See Managing Query Performance - push.filters for more information.
cardinalityinteger (+ two keywords low and high).scopeSuggests the cardinality of the following graph pattern. See Managing Query Performance - cardinality for more information.
evaluateon,offscopeSuggests to evaluate the scope at query optimization time. <br><br>See Managing Query Performance - Scope Evaluation Hints for more information.
evaluate.limitintegerscopeLimits the number of results that a pattern evaluated at optimization time is allowed to produce.
evaluate.limitintegerscopeLimits the number of results that a pattern evaluated at optimization time is allowed to produce. <br><br>See Managing Query Performance - Scope Evaluation Hints for more information.
query.decompositiondefault, aggressive, or offscopeSpecifies query decomposition strategy: <br><br> - aggressive: always decompose joins on the subject variable <br><br> - default: let the optimizer decide based on other factors, e.g. available indexes <br><br> - off: don't decompose group graph patterns.
query.join.decompositiondefault, aggressive, or offscopeEnables the optimizer to decompose query patterns in order to prevent non-selective joins before main optimization phase: <br><br> - aggressive: always prefer to prevent non-selective joins <br><br> - default: let the optimizer decide based on join selectivity <br><br> - off: don't decompose group graph patterns along non-selective joins.

Query Runtime Hints

Differently from the optimization hints, these hints may affect the execution of the query beyond the optimization phase. Generally they don’t change results but can have a performance impact.

Hint NamePossible ValuesPositionDescription
executorauto,legacypreambleChoses the execution engine used.<br><br> - If legacy, the 10.1 query execution engine will be used.
plan.cacheon,offpreambleToggles plan cache for this query.<br><br> - If off, the query will be optimized without any plan cache lookup
service.batchintegerscopeSpecifies how many SPARQL SERVICE results will be parsed from the response before processing.
values.id.lazyon,offpreambleIf on, the query engine will try to postpone dictionary encoding for nodes generated during query evaluation until necessary, for example, till a join condition requires it for evaluation.
edge.properties.lookupdirect,inversescopeSpecifies how edge property patterns like <<?s :p ?o>> :q ?t should be evaluated:<br><br>- direct: first by :p (embedded predicate), then by :q (outside predicate)<br><br>- inverse: first by :q (outside predicate), then by :p (embedded predicate)
paths.evaluationlazy or eagerpreambleSpecifies how paths should be traversed:<br><br>- lazy: search is stopped after each new path is found so it can be returned (not available for PATHS ALL queries)<br><br>- eager: all reachable nodes are reached first

Join Control Hints

These hints are the means to avoid particular join algorithms for a (part of) the query. Their syntactic form is #pragma join.{type} off where {type} specifies the join algorithm, i.e. one of:

  • hash
  • directHash
  • sortMerge
  • bind
  • blockBind
  • service
  • multiWayService

These hints should be used conservatively and only when it is clear that some particular type of join is the main performance problem in the query. We generally advise to first try group.joins and cardinality hints to help with the optimization process.

Reasoning Hints

These hints control the query rewriting process when reasoning is enabled. Most of them do not change the results, with the notable exception of reasoning.

Hint NamePossible ValuesPositionDescription
reasoningon, offscopeSpecifies whether query rewriting is on or off for this group graph pattern. Also a result altering hint. See Managing Query Performance - Reasoning for more information.
reasoning.rewritingper_scope, per_patternscopeSpecifies how query rewriting should be done: <br><br> - per_scope: all triple patterns as a group (default) <br><br> - per_pattern: each triple pattern individually (results in smaller rewritings in some cases)
push.reasoningdefault, aggressive, or offscopeSpecifies how the optimizer should try to patterns under reasoning operators like ?s rdf:type ?type <br><br> - aggressive: always push the one which looks the most selective <br><br> - default: the optimizer will decide based on any available criteria <br><br> - off: the optimization is off

Virtual Graph Hints

These hints control the query rewriting and planning process when querying data in Virtual Graphs.

Hint NamePossible ValuesPositionDescription
cached.dataset.namename of dataset, nonepreambleSpecifies name of the cached dataset to use.
virtual.transparencyon, offscopeEnables or disables the Virtual Transparency feature. Also a result altering hint.
vg.union.strategycoalesced, embeddedscopeHow to translate to SQL when the fields for the returned solution can come from multiple mappings: <br><br> - coalesced: returns the fields from each mapping in its own field and null for all other fields. <br><br> - embedded: creates two fields for each result, one for the field’s type and one for the field’s value.
service.prefetch.limitintegerpreambleThe number of solutions which are prefetched from a Virtual Graph during query planning. Note: This query hint only has an effect if the <a href="../../operating-stardog/database-administration/database-configuration#service"><code>service.prefetch.threshold</code></a> value for the database is a positive integer.
virtual.distribute.joinsdefault, always, offscopeDetermines how joins are distributed over unions of Virtual Graphs. Either whenever possible (always), never (off), or based on the cost of distributing the join (default).

Result Altering Hints

These hints change the semantics of the query and thus the results.

Hint NamePossible ValuesPositionDescription
describe.strategydefault, bidirectional, cbd, <custom-strategy>preambleSpecifies the strategy to evaluate DESCRIBE queries (either built-in or custom). See DESCRIBE Queries for more information.
reasoningon, offscopeSpecifies whether query rewriting is on or off for this group graph pattern.
virtual.transparencyon,offscopeEnables or disables the Virtual Transparency feature

Full-text Search Hints

These hints may affect the query rewriting process when full-text search service is in use. The hints target query performance improvement and query results do not change. The purpose of the hints here is to give priority to more selective patterns, when full-text search query is non-selective. See Performance Hints for full-text search for more information.

Hint NamePossible ValuesPositionDescription
search.push.thresholdIntegerscopeCardinality estimation threshold to detect a non-selective full-text search pattern so that more selective parts of the query can be evaluated first.
search.cardinality.thresholdIntegerscopeThreshold of maximum cardinality of patterns that can be selected by the optimizer to evaluate before a full-text search pattern.
search.max.subset.sizeIntegerscopeMaximum number of patterns that can be selected by the optimizer to evaluate before a full-text search pattern.

Federation Hints

These hints control the query planning process when querying federations of SPARQL-based Services. These services include Virtual Graphs, cached Virtual Graphs, other databases, and SPARQL endpoints.

Hint NamePossible ValuesPositionDescription
optimizer.join.order.topkIntegerscopeThe number of alternative query plans generated during robust query planning. A value of 1 disables robust query planning on a per-scope basis. Higher values may entail longer pre-execution times.