SPARQL query hints - Amazon Neptune
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

SPARQL query hints

You can use query hints to specify optimization and evaluation strategies for a particular SPARQL query in Amazon Neptune.

Query hints are expressed using additional triple patterns that are embedded in the SPARQL query with the following parts:

scope hint value
  • scope – Determines the part of the query that the query hint applies to, such as a certain group in the query or the full query.

  • hint – Identifies the type of the hint to apply.

  • value – Determines the behavior of the system aspect under consideration.

The query hints and scopes are exposed as predefined terms in the Amazon Neptune namespace The examples in this section include the namespace as a hint prefix that is defined and included in the query:

PREFIX hint: <>

For example, the following shows how to include a joinOrder hint in a SELECT query:

PREFIX hint: <> SELECT ... { hint:Query hint:joinOrder "Ordered" . ... }

The preceding query instructs the Neptune engine to evaluate joins in the query in the given order and disables any automatic reordering.

Consider the following when using query hints:

  • You can combine different query hints in a single query. For example, you can use the bottomUp query hint to annotate a subquery for bottom-up evaluation and a joinOrder query hint to fix the join order inside the subquery.

  • You can use the same query hint multiple times, in different non-overlapping scopes.

  • Query hints are hints. Although the query engine generally aims to consider given query hints, it might also ignore them.

  • Query hints are semantics preserving. Adding a query hint does not change the output of the query (except for the potential result order when no ordering guarantees are given—that is, when the result order is not explicitly enforced by using ORDER BY).

The following sections provide more information about the available query hints and their usage in Neptune.

Scope of SPARQL query hints in Neptune

The following table shows the available scopes, associated hints, and descriptions for SPARQL query hints in Amazon Neptune. The hint prefix in these entries represents the Neptune namespace for hints:

PREFIX hint: <>
Scope Supported Hint Description


The query hint applies to the whole query.


The time-out value applies to the entire query.


Type promotion is disabled for the entire query.


The query ID value applies to the entire query.


Use of the DFE is enabled (or disabled) for the entire query.


The query hint applies to the top-level elements in the specified group, but not to nested elements (such as subqueries) or parent elements.


The hint is specified and applied to a nested SELECT subquery. The subquery is evaluated independently, without considering solutions computed before the subquery.