Skip to content

pt-mongodb-index-check

Performs checks on MongoDB indexes.

Checks available

Duplicated indexes

Check for indexes that are the prefix of other indexes. For example if we have these 2 indexes

db.getSiblingDB("testdb").test_col.createIndex({"f1": 1, "f2": -1, "f3": 1, "f4": 1}, {"name": "idx_01"});
db.getSiblingDB("testdb").test_col.createIndex({"f1": 1, "f2": -1, "f3": 1}, {"name": "idx_02"});

The index idx_02 is the prefix of idx_01 because it has the same keys in the same order so, idx_02 can be dropped.

Unused indexes.

This check gets the $indexstats for all indexes and reports those having accesses.ops = 0.

Usage

Run the program as pt-mongodb-index-check <command> [flags]

Available commands

Command

Description

check-duplicates

Run checks for duplicated indexes.

check-unused

Run checks for unused indexes.

check-all

Run checks for unused and duplicated indexes.

Available flags

--config=FILE[,FILE,...]

List of Percona Toolkit config files. Must be the first flag.

--all-databases

Check in all databases excluding system DBs.

--databases=DATABASES,...

Comma-separated list of databases to check.

--all-collections

Check in all collections in selected databases.

--collections=COLLECTIONS,...

Comma-separated list of collections to check.

--mongodb.uri=...

Connection URI.

--json

Show output as JSON.

--version-check

Check for updates (enabled by default).

--no-version-check

Disable update checks.

--help

Show help and exit.

--version

Show version information and exit.

Authors

Carlos Salguero

ABOUT PERCONA TOOLKIT

This tool is part of Percona Toolkit, a collection of advanced command-line tools for MySQL developed by Percona. Percona Toolkit was forked from two projects in June, 2011: Maatkit and Aspersa. Those projects were created by Baron Schwartz and primarily developed by him and Daniel Nichter. Visit http://www.percona.com/software/ to learn about other free, open-source software from Percona.

VERSION

pt-mongodb-index-check 3.7.1

For help, click the link below to get free database assistance or contact our experts for personalized support.

Get help from Percona