Skip to content

Conversation

y123456yz
Copy link
Contributor

btree index check, avoid create duplicate btree indexes, Avoid affecting performance

btree index check, avoid create duplicate btree indexes, Avoid affecting performance by the deplicate index.
for example:
add two index: db.collection.createIndex({a:1}) and db.collection.createIndex({a:11})
the tow index are actually the same, One of them is a useless index, but it can affect the insert performance.

In addition, They also affecting query performance because both are candidate indexes. This increases storage consts.

@y123456yz
Copy link
Contributor Author

SERVER-84667

@y123456yz y123456yz changed the title index check, avoid create duplicate btree indexes, Avoid affecting performance SERVER-84667:index check, avoid create duplicate btree indexes, Avoid affecting performance Jan 9, 2024
@mongodt mongodt self-requested a review January 9, 2024 16:52
Copy link
Contributor

@mongodt mongodt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see my inline comments

//For example:
// Add two indexes: db.collection.createIndex({a:1}) and db.collection.createIndex({a:11})
// The two indexes are actually the same, One of them is a useless index
auto dealIndexKeyPattern = [&](const BSONObj& indexKeyPattern) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please capture what is needed, in this case "this". Change [&] to [this].

A better name for dealIndexKeyPattern is canonizeIndexKeyPattern.

@y123456yz
Copy link
Contributor Author

@mongodt
Based on your guidance, I have change the code, please review again.
thanks.

Copy link

@MmdDebian MmdDebian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mongo default language is c++ ?

@kelly-cs
Copy link
Contributor

kelly-cs commented Oct 3, 2025

Closing as SERVER-84667 requires a broader set of changes to index and driver versioning, and was closed.

@kelly-cs kelly-cs closed this Oct 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants