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

Possible bug on indexes usage #197

Open
no-more opened this issue Jan 15, 2017 · 1 comment
Open

Possible bug on indexes usage #197

no-more opened this issue Jan 15, 2017 · 1 comment

Comments

@no-more
Copy link

no-more commented Jan 15, 2017

Hi,

I'm not sure if this is a bug or the expected behavior but I currently have some trouble using secondary indexes.
If the query's parameter is not exactly the same as the index, the index is never used.
The issue is that I can't always control the query fields order as it's an object.
Sometime I could even have some other fields before the indexed once.

Do you think it's possible to make indexes work in any order? If it's too complicated or to costly to handle this automatically, would it be possible to pass the index name manually to the function ?

Thanks a lot.

@no-more
Copy link
Author

no-more commented Jan 15, 2017

Here is an example :

        dbCollection.ensureIndex(
            {
                targetId: 1,
                targetType: 1,
            }
        );
dbCollection.explain({targetType: "52", targetId: "52", "test": "45"});// -> no index used
dbCollection.explain({"test": "45", targetId: "52", targetType: "52"});// -> no index used
dbCollection.explain({targetId: "52", targetType: "52", "test": "45"});// -> index used

Thanks.

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

No branches or pull requests

1 participant