Settings and Parameters
You can configure the Query service using cluster-level query settings, node-level query settings, and request-level query parameters.
There are three ways of configuring the Query service. You can specify cluster-level settings for all nodes running the Query service in the cluster. You can specify node-level settings for a single node running the Query service. You can also specify parameters for individual requests. Cluster-level query settings, node-level query settings, and request-level parameters must be set and used in different ways.
Setting Per | Set By | Set On | Set Via | |
---|---|---|---|---|
Cluster-level query settings |
Cluster |
The administrator at the system level |
Server side |
The CLI, cURL statements, or the UI |
Node-level query settings |
Service Node |
The administrator at the system level |
Server side |
cURL statements |
Request-level parameters |
Request (statement) |
Each user |
Client side |
|
Cluster-level settings and node-level settings are collectively referred to as service-level settings. |
Query Setting Levels and Equivalents
Some query settings are cluster-level, node-level, or request-level only, while some apply to more than one level with slightly different names.
If a cluster-level setting has an equivalent node-level setting, then changing the cluster-level setting overwrites the node-level setting for all Query nodes in the cluster.
You can change a node-level setting for a single node to be different to the equivalent cluster-level setting. Changing the node-level setting does not affect the equivalent cluster-level setting. However, you should note that the node-level setting may be overwritten by subsequent changes at the cluster-level. In particular, specifying query settings via the CLI or the UI makes changes at the cluster-level.
If a request-level parameter has an equivalent node-level setting, the node-level setting usually acts as the default for the request-level parameter, as described in the tables below. Setting a request-level parameter overrides the equivalent node-level setting.
Furthermore, for numeric values, if a request-level parameter has an equivalent node-level setting, the node-level setting dictates the upper-bound value of the request-level parameter.
For example, if the node-level timeout
is set to 500, then the request-level parameter cannot be set to 501 or any value higher.
Cluster-Level Only Settings | Node-Level Only Settings | Request-Level Only Parameters |
---|---|---|
Cluster-Level Name | Node-Level Name | Request-Level Name |
---|---|---|
N/A |
Cluster-Level Name | Node-Level Name | Request-Level Name |
---|---|---|
N/A |
Cluster-Level Name | Node-Level Name | Request-Level Name |
---|---|---|
Cluster-Level Query Settings
To set a cluster-level query setting, use the Query Settings REST API (/settings/querySettings
endpoint) with a cURL statement, or the Advanced Query Settings in the Couchbase Web Console.
You can also set all of the cluster-level query settings, except for the CURL() access list settings, using the setting-query command.
The table below contains details of all cluster-level query settings.
Name | Description | Schema | ||
---|---|---|---|---|
queryCompletedLimit |
Sets the number of requests to be logged in the completed requests catalog. As new completed requests are added, old ones are removed. Increase this when the completed request keyspace is not big enough to track the slow requests, such as when you want a larger sample of slow requests. Refer to Configure the Completed Requests for more information and examples. The node-level |
integer (int32) |
||
queryCompletedThreshold |
A duration in milliseconds. All completed queries lasting longer than this threshold are logged in the completed requests catalog. Specify Refer to Configure the Completed Requests for more information and examples. The node-level |
integer (int32) |
||
queryLogLevel |
Log level used in the logger. All values, in descending order of data:
The node-level |
enum (DEBUG, TRACE, INFO, WARN, ERROR, SEVERE, NONE) |
||
queryMaxParallelism |
Specifies the maximum parallelism for queries on all Query nodes in the cluster. If the value is zero or negative, the maximum parallelism is restricted to the number of allowed cores. Similarly, if the value is greater than the number of allowed cores, the maximum parallelism is restricted to the number of allowed cores. (The number of allowed cores is the same as the number of logical CPUs. In Community Edition, the number of allowed cores cannot be greater than 4. In Enterprise Edition, there is no limit to the number of allowed cores.) The node-level In addition, there is a request-level
Refer to Max Parallelism for more information. |
integer (int32) |
||
queryN1qlFeatCtrl |
N1QL feature control. This setting is provided for technical support only. The node-level |
integer (int32) |
||
queryPipelineBatch |
Controls the number of items execution operators can batch for Fetch from the KV. The node-level In addition, the request-level |
integer (int32) |
||
queryPipelineCap |
Maximum number of items each execution operator can buffer between various operators. The node-level In addition, the request-level |
integer (int32) |
||
queryPreparedLimit |
Maximum number of prepared statements in the cache. When this cache reaches the limit, the least recently used prepared statements will be discarded as new prepared statements are created. The node-level |
integer (int32) |
||
queryScanCap |
Maximum buffered channel size between the indexer client and the query service for index scans. This parameter controls when to use scan backfill. Use The node-level In addition, the request-level |
integer (int32) |
||
queryTimeout |
Maximum time to spend on the request before timing out (ns). Specify The node-level In addition, the request-level The cluster-level |
integer (int64) |
||
queryTmpSpaceDir |
The path to which the indexer writes temporary backfill files, to store any transient data during query processing. The specified path must already exist. Only absolute paths are allowed. The default path is |
string |
||
queryTmpSpaceSize |
The maximum size of temporary backfill files (MB). Setting the size to The maximum size is limited only by the available disk space. |
integer (int32) |
||
queryCurlWhitelist |
An object which determines which URLs may be accessed by the |
Access
Name | Description | Schema |
---|---|---|
all_access |
Defines whether the user has access to all URLs, or only URLs specified by the access list. This field set must be set to Setting this field to |
boolean |
allowed_urls |
An array of strings, each of which is a URL to which you wish to grant access. Each URL is a prefix match. The CURL() function will allow any URL that starts with this value. For example, if you wish to allow access to all Google APIs, add the URL Note that each URL must include the port, protocol, and all other components of the URL. |
< string > array |
disallowed_urls |
An array of strings, each of which is a URL that will be restricted for all roles. Each URL is a prefix match. The CURL() function will disallow any URL that starts with this value. If both Note that each URL must include the port, protocol, and all other components of the URL. |
< string > array |
Node-Level Query Settings
To set a node-level query setting, use the Admin REST API (/admin/settings
endpoint) with a cURL statement.
These settings cannot be set by cbq .
|
To see a list of the current Query Settings, while the Query Service is running, enter:
$ curl http://hostname:8093/admin/settings -u user:pword
This will output the entire list of node-level query settings:
{"auto-prepare":false,"completed":{"aborted":null,"threshold":1000},"completed-limit":4000,"completed-threshold":1000,"controls":false,"cpuprofile":"","debug":false,"functions-limit":16384,"keep-alive-length":16384,"loglevel":"INFO","max-index-api":4,"max-parallelism":1,"memprofile":"","mutexprofile":false,"n1ql-feat-ctrl":12,"pipeline-batch":16,"pipeline-cap":512,"prepared-limit":16384,"pretty":false,"profile":"off","request-size-cap":67108864,"scan-cap":512,"servicers":4,"timeout":0}
To output to a file for editing multiple settings at a single time, add the -o filename
option.
For example:
$ curl http://hostname:8093/admin/settings -u user:pword -o settings.txt
The table below contains details of all node-level query settings.
Name | Description | Schema | ||
---|---|---|---|---|
auto-prepare |
Specifies whether the query engine should create a prepared statement every time a N1QL request is submitted, whether the PREPARE statement is included or not. Refer to Auto-Prepare for more information. |
boolean |
||
completed |
A nested object that sets the parameters for the completed requests catalog. All completed requests that match these parameters are tracked in the completed requests catalog. Refer to Configure the Completed Requests for more information and examples. |
|||
completed-limit |
Sets the number of requests to be logged in the completed requests catalog. As new completed requests are added, old ones are removed. Increase this when the completed request keyspace is not big enough to track the slow requests, such as when you want a larger sample of slow requests. Refer to Configure the Completed Requests for more information and examples. The cluster-level |
integer (int32) |
||
completed-threshold |
A duration in milliseconds. All completed queries lasting longer than this threshold are logged in the completed requests catalog. Specify Refer to Configure the Completed Requests for more information and examples. The cluster-level |
integer (int32) |
||
controls |
Specifies if there should be a controls section returned with the request results. When set to
The request-level |
boolean |
||
cpuprofile |
The absolute path and filename to write the CPU profile to a local file. The output file includes a controls section and performance measurements, such as memory allocation and garbage collection, to pinpoint bottlenecks and ways to improve your code execution. To stop
Default : |
string |
||
debug |
Use debug mode. When set to |
boolean |
||
distribute |
This field is only available with the POST method.
When specified alongside other settings, this field instructs the node that is processing the request to cascade those settings to all other query nodes.
The actual value of this field is ignored. |
boolean |
||
keep-alive-length |
Maximum size of buffered result. |
integer (int32) |
||
loglevel |
Log level used in the logger. All values, in descending order of data:
The cluster-level |
enum (DEBUG, TRACE, INFO, WARN, ERROR, SEVERE, NONE) |
||
max-index-api |
Max index API. This setting is provided for technical support only. |
integer (int32) |
||
max-parallelism |
Specifies the maximum parallelism for queries on this node. If the value is zero or negative, the maximum parallelism is restricted to the number of allowed cores. Similarly, if the value is greater than the number of allowed cores, the maximum parallelism is restricted to the number of allowed cores. (The number of allowed cores is the same as the number of logical CPUs. In Community Edition, the number of allowed cores cannot be greater than 4. In Enterprise Edition, there is no limit to the number of allowed cores.) The cluster-level In addition, there is a request-level
Refer to Max Parallelism for more information. |
integer (int32) |
||
memprofile |
Filename to write the diagnostic memory usage log. To stop
Default : |
string |
||
mutexprofile |
Mutex profile.
This setting is provided for technical support only. |
boolean |
||
n1ql-feat-ctrl |
N1QL feature control. This setting is provided for technical support only. The cluster-level |
integer (int32) |
||
pipeline-batch |
Controls the number of items execution operators can batch for Fetch from the KV. The cluster-level In addition, the request-level |
integer (int32) |
||
pipeline-cap |
Maximum number of items each execution operator can buffer between various operators. The cluster-level In addition, the request-level |
integer (int32) |
||
prepared-limit |
Maximum number of prepared statements in the cache. When this cache reaches the limit, the least recently used prepared statements will be discarded as new prepared statements are created. The cluster-level |
integer (int32) |
||
pretty |
Specifies whether query results are returned in pretty format. The request-level |
boolean |
||
profile |
Specifies if there should be a profile section returned with the request results. The valid values are:
Refer to Monitoring and Profiling Details for more information and examples. The request-level |
enum (off, phases, timings) |
||
request-size-cap |
Maximum size of a request. |
integer (int32) |
||
scan-cap |
Maximum buffered channel size between the indexer client and the query service for index scans. This parameter controls when to use scan backfill. Use The cluster-level In addition, the request-level |
integer (int32) |
||
servicers |
The number of service threads for the query. |
integer (int32) |
||
timeout |
Maximum time to spend on the request before timing out (ns). Specify The cluster-level In addition, the request-level The node-level |
integer (int64) |
Logging parameters
Name | Description | Schema |
---|---|---|
aborted |
If true, all requests that generate a panic are logged. |
boolean |
client |
The IP address of the client.
If specified, all completed requests from this IP address are logged. |
string |
context |
The opaque ID or context provided by the client. If specified, all completed requests with this client context ID are logged. Refer to the request-level |
string |
error |
An error number.
If specified, all completed queries returning this error number are logged. |
integer (int32) |
tag |
A unique string which tags a set of qualifiers. Refer to Configure the Completed Requests for more information. |
string |
threshold |
A duration in milliseconds. If specified, all completed queries lasting longer than this threshold are logged. This is another way of specifying the node-level |
integer (int32) |
user |
A user name, as given in the request credentials.
If specified, all completed queries with this user name are logged. |
string |
Request-Level Parameters
To set a request-level parameter, use the N1QL REST API (/query/service
endpoint) with a cURL statement, or the cbq command, or a client program.
While cbq
is a sandbox to test code on your local machine, your production query settings are set with the cURL commands on your server.
The table below contains details of all request-level parameters, along with examples.
Name | Description | Schema | ||||
---|---|---|---|---|---|---|
args |
If the statement has 1 or more positional parameters, this parameter needs to be in the request; this is an array of JSON values, one for each positional parameter in the statement.
See section Named Parameters VS. Positional Parameters for details. Example
|
array |
||||
auto_execute |
Specifies that prepared statements should be executed automatically as soon as they are created. This saves you from having to make two separate requests in cases where you want to prepare a statement and execute it immediately. Refer to Auto-Execute for more information. Default
Example
|
boolean |
||||
batch_args |
Applies to POST requests only, containing UPDATE, INSERT, DELETE statements (DML statements) with positional parameters. Example
These require the values to be given in
|
array of arrays |
||||
batch_named_args |
Applies to POST requests only, containing UPDATE, INSERT, DELETE statements (DML statements) with named parameters. Example
These require the values to be given in
|
array of objects |
||||
client_context_id |
A piece of data supplied by the client that is echoed in the response, if present. N1QL is agnostic about the content of this parameter; it is just echoed in the response.
|
string |
||||
compression |
Compression format to use for response data on the wire. Values are case-insensitive. Default
Example
|
enum (ZIP, RLE, LZMA, LZO, NONE) |
||||
controls |
Specifies if there should be a controls section returned with the request results. When set to
The node-level Example
|
boolean |
||||
creds |
Specify the login credentials in the form of You can specify credentials for different buckets by separating them with a comma. If credentials are supplied in the request header, then Example
|
array |
||||
encoded_plan |
In Couchbase Server 6.5 and later, this parameter is ignored and has no effect. It is included for compatibility with previous versions of Couchbase Server. |
string |
||||
encoding |
Desired character encoding for the query results. Only possible value is Default
|
string |
||||
format |
Desired format for the query results. Values are case-insensitive. Default
Example
|
enum (JSON, XML, CSV, TSV) |
||||
max_parallelism |
Specifies the maximum parallelism for the query. The node-level In addition, the cluster-level
Default
The same as the number of partitions of the index selected for the query. Example
|
integer (int32) |
||||
metrics |
Specifies that metrics should be returned with query results. Default
Example
|
boolean |
||||
namespace |
Specifies the namespace to use. Example
|
string |
||||
pipeline_batch |
Controls the number of items execution operators can batch for Fetch from the KV. The node-level In addition, the cluster-level Example
|
integer (int32) |
||||
pipeline_cap |
Maximum number of items each execution operator can buffer between various operators. The node-level In addition, the cluster-level Example
|
integer (int32) |
||||
prepared |
The prepared form of the N1QL statement to be executed.
Example
Prepare the query result of the most expensive hotel:
Response:
Execute the prepared statement:
|
string |
||||
pretty |
Specifies the query results returned in pretty format. The node-level Example
|
boolean |
||||
profile |
Specifies if there should be a profile section returned with the request results. The valid values are:
The node-level Example
|
enum (off, phases, timings) |
||||
readonly |
Controls whether a query can change a resulting recordset. If
Default
Example
|
boolean |
||||
scan_cap |
Maximum buffered channel size between the indexer client and the query service for index scans. This parameter controls when to use scan backfill. Use The node-level In addition, the cluster-level Example
|
integer (int32) |
||||
scan_consistency |
Specify the consistency guarantee/constraint for index scanning. The valid values are:
Values are case-insensitive. Default
Example
|
enum (not_bounded, at_plus, request_plus, statement_plus) |
||||
scan_vector |
Specify the lower bound vector timestamp for one bucket when using Scan vectors are built of two-element [
Scan vectors have two forms:
For queries referencing multiple buckets, use Example
|
array, object |
||||
scan_vectors |
A map from bucket names to scan vectors.
See The scan vectors can be Full or Sparse. |
object |
||||
scan_wait |
Can be supplied with Specifies the maximum time the client is willing to wait for an index to catch up to the vector timestamp in the request.
Its format includes an amount and a mandatory unit, e.g.
Default
Example
|
string (duration) |
||||
signature |
Include a header for the results schema in the response. Default
Example
|
boolean |
||||
statement |
Any valid N1QL statement for a POST request, or a read-only N1QL statement (SELECT, EXPLAIN) for a GET request.
|
string |
||||
timeout |
Maximum time to spend on the request before timing out. Specify a duration of The node-level In addition, the cluster-level The request-level
Example
|
string (duration) |
||||
$<identifier> |
If the A named parameter consists of two parts:
Named parameters apply to See section Named Parameters VS. Positional Parameters for examples. |
JSON value |
Named Parameters VS. Positional Parameters
Named Parameters use a variable name to refer to each one, while Positional Parameters refer to the position each variable is used. As summarized in the below table, these two types of requests should contain the following parameters:
Statement | Args | |
---|---|---|
Named Parameters |
|
$nval = "smith" $aval = 45 |
Positional Parameters |
|
[ "smith", 45 ] |
Positional Parameters can also be specified in a statement using ? as an alternative way to specify the same query. |
Related Links
For more details about the N1QL REST API, refer to N1QL REST API.
For more details about the Admin REST API, refer to Admin REST API.
For more details about the Query Settings API, refer to Cluster Query Settings API.
For more details about API content and settings, refer to REST API reference.