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
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
)?What version of Go are you using (
go version
)?What operating system and processor architecture are you using (
go env
)?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