Skip to content

Query Threading

Query Threading is a powerful feature that enables individual queries to run across multiple threads in parallel. It’s especially effective for complex graph traversals or queries that touch a large number of elements, such as stepping off supernodes with hundreds of thousands of edges. By distributing the work, you can dramatically boost performance and reduce response times for heavy-duty operations.

Standard query execution

With the default configurations, each Gremlin query in AGS executes on a single thread from the thread pool controlled by the aerospike.graph-service.gremlinPool configuration parameter. This single-threaded execution can become a bottleneck when processing queries that touch hundreds of thousands of graph elements. For example, traversing supernodes (vertices with extremely high connectivity) or performing a deep multi-hop query with high connectivity on each hop.

Threaded query execution

Query Threading is configured with aerospike.graph.parallelize, which enables individual queries to utilize multiple threads during execution, distributing the workload across available compute resources. This threaded execution model is particularly effective for I/O-bound operations in which the query spends significant time waiting for data retrieval from the Aerospike database.

When to use parallel query execution

Query Threading is particularly beneficial for:

  • High fan-out queries: queries that expand to touch many vertices from a single starting point.
  • Supernode processing: queries involving vertices with thousands to hundreds of thousands of edges.

How to use parallel query execution

To enable Query Threading for a specific query, include the aerospike.graph.parallelize parameter in your query as shown below.

g.with("aerospike.graph.parallelize", <NUM-THREADS>).<QUERY>

Batch vs single record reads

Threading runs your query across multiple threads. Batching decides how each thread reads records.

Batch reading controls

Batch reading is governed by three settings:

See Graph configuration options for threshold and sizing details.

Pagination controls

Pagination uses two settings:

Feedback

Was this page helpful?

What type of feedback are you giving?

What would you like us to know?

+Capture screenshot

Can we reach out to you?