Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SERVER-84667:index check, avoid create duplicate btree indexes, Avoid affecting performance #1588

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

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

@MohamadMirzaeiDev MohamadMirzaeiDev 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++ ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants