Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MongoDB Indexes

The documentation says: If you have a compound index on multiple fields, you can use it to query on the beginning subset of fields. So if you have an index on a,b,c you can use it query on a a,b a,b,c

My question is, if I have a compound index like a,b,c can I query on a,c and sort on c?

like image 479
strickland Avatar asked Feb 09 '26 16:02

strickland


1 Answers

It looks like this question was answered on the Google Groups:

Not efficiently, no. Take a look at the explain() from queries to see what happens.

like image 175
Gates VP Avatar answered Feb 13 '26 20:02

Gates VP



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!