PT-2516 - enhance pt-mongodb-index-check unused and duplicate analysis#1132
Open
jenunes wants to merge 1 commit into
Open
PT-2516 - enhance pt-mongodb-index-check unused and duplicate analysis#1132jenunes wants to merge 1 commit into
jenunes wants to merge 1 commit into
Conversation
Multi-signal unused index scoring: - Collect $indexStats, listIndexes, collStats, and serverStatus - Score indexes into tiers: SAFE_TO_DROP, LIKELY_UNUSED, LOW_USAGE, MONITOR, KEEP - Hard guards for _id_, unique, TTL, hidden, partial, and system indexes - Warmup period detection (configurable --warmup-days) - Cross-reference duplicate prefix indexes with container usage Duplicate detection improvements: - keyToken distinguishes hashed/text/2dsphere/2d from btree directions - Handle primitive.Symbol decoding (MongoDB 8.x) - Skip _id_ as a droppable prefix candidate - Property-aware: partialFilterExpression, sparse, collation checked - Unique prefix warning when dropping would lose uniqueness - Rich sectioned text report with Reason, Action, optional index sizes Sharded cluster support: - Aggregate $indexStats across shards (sum ops, oldest since) - NormalizeIndexStat for mongos responses missing top-level name/key - DeduplicateIndexRecords safety net Connection and UX: - Ping after connect for immediate auth/network errors - Require --databases or --all-databases (or DB in URI) - Skip system databases (admin, config, local) and system.* collections - collStats IndexSizes uses dynamic map for arbitrary index names Documentation: - README.rst rewritten with new flags, sample output, sharded behavior, edge cases (warmup, read preference, background builds), PTDEBUG usage Tests: - 41 unit/regression tests covering scoring, duplicate detection, report rendering, system DB filtering, URI parsing, and sharded aggregation Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Multi-signal unused index scoring:
Duplicate detection improvements:
Sharded cluster support:
Connection and UX:
Documentation:
Tests:
41 unit/regression tests covering scoring, duplicate detection, report rendering, system DB filtering, URI parsing, and sharded aggregation
The contributed code is licensed under GPL v2.0
Contributor Licence Agreement (CLA) is signed
util/update-modules has been ran
Documentation updated
Test suite update