0

This question on MongoDB compound index:

Below is a sample document in a given collection test.
{ a : 5, b : 3, c: 2, d : 1 }
Given a compound index { a: 1, b:1, c:1, d:1}, Which of the below query will not use in-memory sorting? Select all valid.
A) db.test.find( { a: 5, b: 3 } ).sort( { c: 1, d : 1 } )
B) db.test.find( { a: 5, b: 3 } ).sort( { a: 1} )
C) db.test.find( { a: 5, b: 3 } ).sort( { a: 1, b: 1, c: 1 } )
D) db.test.find( { a: 5, b: 3 } ).sort( { c: 1 } )

My understanding is A, B, C, D will all be able to use the compound index, without the need for in-memory sorting. However I've asked around, even asked different AI agents, but all have different answers. Would anyone take a shot at answering this?

asked 16 hours ago

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.