- Reference >
- Database Commands >
- Administration Commands >
- setIndexCommitQuorum
setIndexCommitQuorum¶
New in version 4.4.
-
setIndexCommitQuorum
¶ Changes the minimum number of data-bearing members (i.e commit quorum), including the primary, that must complete an in-progress simultaneous index build before the primary marks those indexes as ready.
The command has the following syntax:
The command takes the following parameters:
Field Type Description setIndexCommitQuorum string
The name of the collection for which the indexes are being built.
indexNames array
An array of in-progress index builds to modify. Each element of the array must be the name of the index.
The indexes specified to
indexNames
must be the entire set of in-progress builds associated to a given index builder, i.e. the indexes built by a singlecreateIndexes
ordb.collection.createIndexes()
operation.commitQuorum int
orstring
The minimum number of data-bearing voting replica set members (i.e. commit quorum), including the primary, that must report a successful index build before the primary marks the
indexes
as ready. A “voting” member is any replica set member wheremembers[n].votes
is greater than0
.Supports the following values:
"votingMembers"
- all data-bearing voting replica set members. (Default)"majority"
- a simple majority of data-bearing voting replica set members.<int>
- a specific number of data-bearing voting replica set members. Specify an integer greater than0
.- A replica set tag name.
comment
any Optional. A user-provided comment to attach to this command. Once set, this comment appears alongside records of this command in the following locations:
- mongod log messages, in the
attr.command.cursor.comment
field. - Database profiler output, in the
command.comment
field. currentOp
output, in thecommand.comment
field.
A comment can be any valid BSON type (string, integer, object, array, etc).
New in version 4.4.
Behavior¶
Requires featureCompatibilityVersion
4.4+
Each mongod
in the replica set or sharded cluster
must have featureCompatibilityVersion set to at
least 4.4
to start index builds simultaneously across
replica set members.
MongoDB 4.4 running featureCompatibilityVersion: "4.2"
builds
indexes on the primary before replicating the index build to
secondaries.
Issuing setIndexCommitQuorum
has no effect on index builds
started with commitQuorum of
0
.
Examples¶
Starting with MongoDB 4.4, index builds on a replica set or sharded
cluster build simultaneously across all data-bearing replica set
members. For sharded clusters, the index build occurs only on shards
containing data for the collection being indexed. The primary
requires a minimum number of data-bearing voting
members (i.e commit quorum), including itself,
that must complete the build before marking the index as ready for
use. See Index Builds in Replicated Environments for more
information.
The following operation starts an index build of two indexes:
By default, index builds use "votingMembers"
commit quorum, or all
data-bearing voting replica set members. The following operation
modifies the index build commit quorum to "majority"
, or a
simple majority of data-bearing voting members:.
- The indexes specified to
indexNames
must be the entire set of in-progress builds associated to a given index builder, i.e. thecreateIndexes()
operation. - The
indexNames
field specifies the names of the indexes. Since the indexes were created without an explicit name, MongoDB generated an index name by concatenating the names of the indexed fields and the sort order.