1

Are the following logical equivalent queries handled by the server differently?

{"Name":"1"}

{$and:[{"Name":"1"},{$or:[{"Name":"1"},{"Tag":"a"}]}]}

Since the second query include the "Tag" field, does it affect index usage?

1
  • Your query doesn't make any sense Commented Feb 7, 2016 at 8:21

1 Answer 1

1

If you want to experiment and see what mongo is doing for each query you can use an explainable object in the mongo shell.

I cannot answer your question since you do not provide information about the indexes defined in your database, but using this you can see it by yourself in the "queryPlanner" section. If it's using an index it shows "IXSCAN" at "stage" field.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.