ArangoDB v3.13 is under development and not released yet. This documentation is not final and potentially incomplete.
Working with multi-dimensional indexes
Create a multi-dimensional index
collection-name
, if
it does not already exist. The call expects an object containing the index
details.estimates boolean (default:
true
)This attribute controls whether index selectivity estimates are maintained for the index. Not maintaining index selectivity estimates can have a slightly positive impact on write performance.
The downside of turning off index selectivity estimates is that the query optimizer is not able to determine the usefulness of different competing indexes in AQL queries when there are multiple candidate indexes to choose from.
The
estimates
attribute is optional and defaults totrue
if not set. It has no effect on indexes other thanpersistent
,mdi
, andmdi-prefixed
. It cannot be disabled for non-uniquemdi
indexes because they have a fixed selectivity estimate of1
.storedValues array of strings
The optional
storedValues
attribute can contain an array of paths to additional attributes to store in the index. These additional attributes cannot be used for index lookups or for sorting, but they can be used for projections. This allows an index to fully cover more queries and avoid extra document lookups.You can have the same attributes in
storedValues
andfields
as the attributes infields
cannot be used for projections, but you can also store additional attributes that are not listed infields
. Attributes instoredValues
cannot overlap with the attributes specified inprefixFields
. There is no reason to store them in the index because you need to specify them in queries in order to usemdi-prefixed
indexes.You cannot create multiple multi-dimensional indexes with the same
sparse
,unique
,fields
and (formdi-prefixed
indexes)prefixFields
attributes but differentstoredValues
settings. That means the value ofstoredValues
is not considered by index creation calls when checking if an index is already present or needs to be created.In unique indexes, only the index attributes in
fields
and (formdi-prefixed
indexes)prefixFields
are checked for uniqueness. The index attributes instoredValues
are not checked for their uniqueness.Non-existing attributes are stored as
null
values insidestoredValues
.The maximum number of attributes in
storedValues
is 32.
Examples
Creating a multi-dimensional index
curl -X POST --header 'accept: application/json' --data-binary @- --dump - http://localhost:8529/_api/index?collection=intervals
{
"type": "mdi",
"fields": [
"from",
"to"
],
"fieldValueTypes": "double"
}
Creating a prefixed multi-dimensional index
curl -X POST --header 'accept: application/json' --data-binary @- --dump - http://localhost:8529/_api/index?collection=intervals
{
"type": "mdi-prefixed",
"fields": [
"from",
"to"
],
"fieldValueTypes": "double",
"prefixFields": [
"year",
"month"
]
}