IndexUse
Read onlyYes
A single index that the optimizer chose to use for a query, as reported by an `IndexNode` of an {@see ExplainResult}.
This is the typed answer to "which indexes does my query actually use?".
Tags
Table of Contents
Properties
- $collection : string|null
- $fields : array<string|int, mixed>
- $name : string
- $selectivityEstimate : float|null
- $sparse : bool
- $type : string
- $unique : bool
Methods
- __construct() : mixed
- fromArray() : self
- Builds an {@see IndexUse} from a raw index entry of an `IndexNode`, with the owning collection threaded in from the node.
Properties
$collection
public
string|null
$collection
= null
$fields
public
array<string|int, mixed>
$fields
= []
$name
public
string
$name
$selectivityEstimate
public
float|null
$selectivityEstimate
= null
$sparse
public
bool
$sparse
= false
$type
public
string
$type
$unique
public
bool
$unique
= false
Methods
__construct()
public
__construct(string $name, string $type[, string|null $collection = null ][, array<int, string> $fields = [] ][, bool $unique = false ][, bool $sparse = false ][, float|null $selectivityEstimate = null ]) : mixed
Parameters
- $name : string
-
The index name.
- $type : string
-
The index type (
primary,persistent,geo,vector, …). - $collection : string|null = null
-
The collection the index belongs to (when known).
- $fields : array<int, string> = []
-
The document attributes covered by the index.
- $unique : bool = false
-
Whether the index enforces uniqueness.
- $sparse : bool = false
-
Whether the index is sparse.
- $selectivityEstimate : float|null = null
-
The optimizer's selectivity estimate (0 … 1), when available.
fromArray()
Builds an {@see IndexUse} from a raw index entry of an `IndexNode`, with the owning collection threaded in from the node.
public
static fromArray(array<string, mixed> $index[, string|null $collection = null ]) : self
Parameters
- $index : array<string, mixed>
-
A single entry of the node's
indexesarray. - $collection : string|null = null
-
The node's collection, if known.