Will This Query and Sort use the Indexing in mongoDB?
-
If we create the following index: { a: 1, b: 1, c: 1, d: 1 } Will the following query and sort operations use the index? db.collection.find({a:5,f:7,h:9).sort( { a:1 } )
-
Answer:
cursor.explain() provides an information about the query plan. Just append ".explain()" to your query, and run it, and you'll figure out whether it's using your indices. For more information, refer to this document: http://docs.mongodb.org/manual/reference/method/cursor.explain/
Michael Spector at Quora Visit the source
Other answers
I do not think you got the request syntax fully right. In general it should use index. Best is to use explain to confirm. Use "hint" with explain, so it will not reevaluate query plan. Regards, Ron http://www.enteros.com
Ron Warshawsky
Related Q & A:
- How to query by datetime in Doctrine MongoDB ODM?Best solution by Stack Overflow
- How can we use MongoDb with postgresql?Best solution by Stack Overflow
- Could we use wifi in the philippines? i mean if u have a wifi enabled phone/laptop, will u be able to use it?Best solution by Yahoo! Answers
- Will I tan if I use a tanning oil with SPF 15?Best solution by answers.yahoo.com
- If i buy an iphone in the US, will I be able to use it in India?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.