ForOptions extends QueryOptions
Table of Contents
Constants
- CACHE_ENABLED : string = 'cacheEnabled'
- DEDUPLICATE : string = 'deduplicate'
- DISABLE_INDEX : string = 'disableIndex'
- ESTIMATES : string = 'estimates'
- EXCLUSIVE : string = 'exclusive'
- EXPIRE_AFTER : string = 'expireAfter'
- FIELD_VALUE_TYPES : string = 'fieldValueTypes'
- FIELDS : string = 'fields'
- FORCE_INDEX_HINT : string = 'forceIndexHint'
- GEO_JSON : string = 'geoJson'
- IGNORE_ERRORS : string = 'ignoreErrors'
- IGNORE_REVS : string = 'ignoreRevs'
- IN_BACKGROUND : string = 'inBackground'
- INDEX_HINT : string = 'indexHint'
- KEEP_NULL : string = 'keepNull'
- LEGACY_POLYGONS : string = 'legacyPolygons'
- LOOKAHEAD : string = 'lookahead'
- MAX_PROJECTIONS : string = 'maxProjections'
- MERGE_OBJECTS : string = 'mergeObjects'
- METHOD : string = 'method'
- NAME : string = 'name'
- OVERWRITE_MODE : string = 'overwriteMode'
- PARALLELISM : string = 'parallelism'
- PARAMS : string = 'params'
- PREFIX_FIELDS : string = 'prefixFields'
- READ_OWN_WRITES : string = 'readOwnWrites'
- REFILL_INDEX_CACHES : string = 'refillIndexCaches'
- SPARSE : string = 'sparse'
- STORED_VALUE : string = 'storedValue'
- TYPE : string = 'type'
- UNIQUE : string = 'unique'
- USE_CACHE : string = 'useCache'
- WAIT_FOR_SYNC : string = 'waitForSync'
Properties
- $disableIndex : bool
- In some rare cases it can be beneficial to not do an index lookup or scan, but to do a full collection scan.
- $forceIndexHint : bool
- Index hints are not enforced by default. If forceIndexHint is set to true, then an error is generated if indexHint does not contain a usable index, instead of using a fallback index or not using an index at all.
- $indexHint : string|null
- For collections, index hints can be given to the optimizer with the indexHint option. The value can be a single index name or a list of index names in order of preference: <code> FOR … IN … OPTIONS { indexHint: "byName" } </code> <code> FOR … IN … OPTIONS { indexHint: ["byName", "byColor"] } </code> Whenever there is a chance to potentially use an index for this FOR loop, the optimizer will first check if the specified index can be used.
- $lookahead : int|null
- The multi-dimensional index types mdi and mdi-prefixed support an optional index hint for tweaking performance: <code> FOR … IN … OPTIONS { lookahead: 32 } </code>
- $maxProjections : int|null
- By default, the query optimizer will consider up to 5 document attributes per FOR loop to be used as projections.
- $useCache : bool
- You can disable in-memory caches that you may have enabled for persistent indexes on a case-by-case basis.
Methods
- __construct() : mixed
- Creates a new QueryOptions instance.
- jsonSerialize() : array<string|int, mixed>
- Invoked to serialize the object with the json serializer.
Constants
CACHE_ENABLED
public
string
CACHE_ENABLED
= 'cacheEnabled'
DEDUPLICATE
public
string
DEDUPLICATE
= 'deduplicate'
DISABLE_INDEX
public
string
DISABLE_INDEX
= 'disableIndex'
ESTIMATES
public
string
ESTIMATES
= 'estimates'
EXCLUSIVE
public
string
EXCLUSIVE
= 'exclusive'
EXPIRE_AFTER
public
string
EXPIRE_AFTER
= 'expireAfter'
FIELD_VALUE_TYPES
public
string
FIELD_VALUE_TYPES
= 'fieldValueTypes'
FIELDS
public
string
FIELDS
= 'fields'
FORCE_INDEX_HINT
public
string
FORCE_INDEX_HINT
= 'forceIndexHint'
GEO_JSON
public
string
GEO_JSON
= 'geoJson'
IGNORE_ERRORS
public
string
IGNORE_ERRORS
= 'ignoreErrors'
IGNORE_REVS
public
string
IGNORE_REVS
= 'ignoreRevs'
IN_BACKGROUND
public
string
IN_BACKGROUND
= 'inBackground'
INDEX_HINT
public
string
INDEX_HINT
= 'indexHint'
KEEP_NULL
public
string
KEEP_NULL
= 'keepNull'
LEGACY_POLYGONS
public
string
LEGACY_POLYGONS
= 'legacyPolygons'
LOOKAHEAD
public
string
LOOKAHEAD
= 'lookahead'
MAX_PROJECTIONS
public
string
MAX_PROJECTIONS
= 'maxProjections'
MERGE_OBJECTS
public
string
MERGE_OBJECTS
= 'mergeObjects'
METHOD
public
string
METHOD
= 'method'
NAME
public
string
NAME
= 'name'
OVERWRITE_MODE
public
string
OVERWRITE_MODE
= 'overwriteMode'
PARALLELISM
public
string
PARALLELISM
= 'parallelism'
PARAMS
public
string
PARAMS
= 'params'
PREFIX_FIELDS
public
string
PREFIX_FIELDS
= 'prefixFields'
READ_OWN_WRITES
public
string
READ_OWN_WRITES
= 'readOwnWrites'
REFILL_INDEX_CACHES
public
string
REFILL_INDEX_CACHES
= 'refillIndexCaches'
SPARSE
public
string
SPARSE
= 'sparse'
STORED_VALUE
public
string
STORED_VALUE
= 'storedValue'
TYPE
public
string
TYPE
= 'type'
UNIQUE
public
string
UNIQUE
= 'unique'
USE_CACHE
public
string
USE_CACHE
= 'useCache'
WAIT_FOR_SYNC
public
string
WAIT_FOR_SYNC
= 'waitForSync'
Properties
$disableIndex
In some rare cases it can be beneficial to not do an index lookup or scan, but to do a full collection scan.
public
bool
$disableIndex
An index lookup can be more expensive than a full collection scan if the index lookup produces many (or even all documents) and the query cannot be satisfied from the index data alone.
Tags
$forceIndexHint
Index hints are not enforced by default. If forceIndexHint is set to true, then an error is generated if indexHint does not contain a usable index, instead of using a fallback index or not using an index at all.
public
bool
$forceIndexHint
FOR … IN … OPTIONS { indexHint: … , forceIndexHint: true }
Tags
$indexHint
For collections, index hints can be given to the optimizer with the indexHint option. The value can be a single index name or a list of index names in order of preference: <code> FOR … IN … OPTIONS { indexHint: "byName" } </code> <code> FOR … IN … OPTIONS { indexHint: ["byName", "byColor"] } </code> Whenever there is a chance to potentially use an index for this FOR loop, the optimizer will first check if the specified index can be used.
public
string|null
$indexHint
In case of an array of indexes, the optimizer will check the feasibility of each index in the specified order. It will use the first suitable index, regardless of whether it would normally use a different index. If none of the specified indexes is suitable, then it falls back to its normal logic to select another index or fails if forceIndexHint is enabled.
Tags
$lookahead
The multi-dimensional index types mdi and mdi-prefixed support an optional index hint for tweaking performance: <code> FOR … IN … OPTIONS { lookahead: 32 } </code>
public
int|null
$lookahead
Tags
$maxProjections
By default, the query optimizer will consider up to 5 document attributes per FOR loop to be used as projections.
public
int|null
$maxProjections
If more than 5 attributes of a collection are accessed in a FOR loop, the optimizer will prefer to extract
the full document and not use projections.
The threshold value of 5 attributes is arbitrary and can be adjusted by using the maxProjections hint.
The default value for maxProjections is 5, which is compatible with the previously hard-coded default value.
For example, using a maxProjections hint of 7, the following query will extract 7 attributes as projections from the original document:
FOR doc IN collection OPTIONS { maxProjections: 7 }
RETURN [ doc.val1, doc.val2, doc.val3, doc.val4, doc.val5, doc.val6, doc.val7 ]
Normally it is not necessary to adjust the value of maxProjections, but there are a few corner cases where it can make sense:
It can be beneficial to increase maxProjections when extracting many small attributes from very large documents,
and a full copy of the documents should be avoided.
It can be beneficial to decrease maxProjections to avoid using projections, if the cost of projections is higher
than doing copies of the full documents. This can be the case for very small documents.
Tags
$useCache
You can disable in-memory caches that you may have enabled for persistent indexes on a case-by-case basis.
public
bool
$useCache
This is useful for queries that access indexes with enabled in-memory caches, but for which it is known
that using the cache will have a negative performance impact.
In this case, you can set the useCache hint to false:
FOR doc IN collection OPTIONS { useCache: false }
FILTER doc.value == @value
...
Tags
Methods
__construct()
Creates a new QueryOptions instance.
public
__construct([array<string|int, mixed>|object|null $init = null ]) : mixed
Parameters
- $init : array<string|int, mixed>|object|null = null
-
A generic object containing properties with which to populate the newly instance. If this argument is null, it is ignored.
jsonSerialize()
Invoked to serialize the object with the json serializer.
public
jsonSerialize() : array<string|int, mixed>