Configure limits on resource usage¶
Add a SET_VAR hint at the start of a GQL query to set options such as its memory limit and execution parallelism. The hint uses /*+ ... */ syntax and applies only to the current query. Subsequent queries continue to use the session configuration.
Common options include:
| Configuration option | Purpose |
|---|---|
memory_limit_bytes |
Memory limit for query execution, in bytes. |
query_concurrency |
Maximum number of execution threads for a single query. |
procedure_minloglevel |
Minimum log level for GQL procedures in the current query. |
The 1 GB data-size limit in NebulaGraph Database Developer Edition restricts how much data an instance can store. memory_limit_bytes limits memory used during query execution. Changing it does not change the data-size limit. See Capabilities and limits for product limits.
Examples¶
The memory and parallelism examples below use the movie graph from the movie example dataset. If you have not loaded the data, follow Load the sample data first.
Run the statements one at a time in CONSOLE in NebulaGraph Studio. In ngql, place each ''' delimiter on its own line around a multiline statement. See Multiline input.
The values query_concurrency=2 and memory_limit_bytes=134217728 illustrate how to set these options. They are not recommended configuration values. Start with the defaults and adjust them for the query and available CPU and memory.
Configure memory limit¶
Set the memory limit for the current query to 128 MiB, or 134217728 bytes (128 × 1024 × 1024 bytes):
/*+ SET_VAR(memory_limit_bytes=134217728) */
USE movie
MATCH (person:Person)
RETURN person
LIMIT 100
If the query exceeds the memory limit, it fails with a memory-limit error. LIMIT 100 limits the number of rows returned; it does not determine the memory limit the query needs.
Configure query parallelism¶
Set the maximum number of execution threads for the current query to 2:
/*+ SET_VAR(query_concurrency=2) */
USE movie
MATCH (person:Person)
RETURN person
LIMIT 100
The actual number of threads depends on the execution plan and available CPU resources. Without this hint, the query uses the session configuration. The system default for this option is 1.
Configure multiple limits¶
Set both the maximum number of execution threads to 2 and the memory limit to 128 MiB for the current query:
/*+ SET_VAR(query_concurrency=2) SET_VAR(memory_limit_bytes=134217728) */
USE movie
MATCH (person:Person)
RETURN person
LIMIT 100
Configure the minimum log level¶
This example uses temporary graph #movie_temporary_graph. Create it first as described in CREATE TEMPORARY GRAPH.
/*+ SET_VAR(procedure_minloglevel="DEBUG") */ USE #movie_temporary_graph {
LOG_DEBUG("This is a debug log")
LOG_INFO("This is an info log")
LOG_WARN("This is a warning log")
LOG_ERROR("This is an error log")
}
The hint sets the minimum procedure log level to DEBUG for the current query, allowing logs at that level or higher to be printed.