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

MongoDB index not being used when querying through mgo on mongoDB views #388

Open
theamazingparas opened this issue Jan 29, 2020 · 0 comments

Comments

@theamazingparas
Copy link

We use the issue tracker to track bugs with mgo - if you have a usage question,
it's best to try Stack Overflow :)

Replace this text with your description, and please answer the questions below
before submitting your issue to help us out. Thanks!


What version of MongoDB are you using (mongod --version)?

4.0.9

What version of Go are you using (go version)?

1.9

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOOS="darwin"

What did you do?

Encountering some issue with indices and mongoDB views.
TL,DR: Index not being used in mongoDB from go client for mongoDB views.
The following is the scenario:
I have a view over a collection and I have added an indices to the underlying collection. When I am doing mongoDB explain from the mongoDB shell the index of the mongoDB collection is being used. It shows IXSCAN in the winning plan. Now I run the query on the view from mongoDB shell only it again uses the index. I am able to check this by checking the index stats of the index.
However, the same is not being used when I am running through the go service using mgo client. It doesn't use index when I run that query on mongoDB view.
Few more caveats :-
Index is being used in some other environment with same mongoDB version and same go library version. The only difference is in the scale. In the environment where it works the no. of docs are 70k~ and in the environment where it doesn't work its around 500k~
The version of mongo being used is 4.09

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