Now you will need more than one index for this query; There is no doubt about that.
The question is which indexes?
Now you should take into account that none of your $or will be able to sort your data in a radically optimal way using the index due to an error in the MongoDB query optimizer: https://jira.mongodb.org/browse/SERVER-1205 .
So, you know that $or will have some sort of performance problems with sorting, and that placing the sort field in the $or sentence indices is useless atm.
So, given that the first index you need is the one that covers the main query you make. Since @Leonid said you can make it a complex index, I would not do it the way he did it. Instead, I would do:
db.col.ensureIndex({type:-1,deleted:-1,date.created:-1})
I am very not sure that the deleted field is in the index in general because of its ultra-low selectivity; it could actually create a less efficient operation (this is true for most databases, including SQL) indexed rather than retrieval. You will need this part for testing; perhaps the field should be the last (?).
Regarding the order of the index, I guessed again. I told DESC for all fields, because your view is DESC, but you need to explain it here.
So this should be able to handle the master clause of your request. Now consider those $or s.
Each $or will use the index separately, and the MongoDB query optimizer will look for indexes for them separately, as if they were separate queries at all, so something worth noting here is a small problem with compound indexes ( http: //docs.mongodb .org / manual / core / indexes / # compound-indexes ) is that they work with prefixes (example here: http://docs.mongodb.org/manual/core/indexes/#id5 ), so you donβt you can make one composite index for all three sentences, therefore a more optimal method of declaring indexes on $or (taking into account the error above):
db.col.ensureindex({creator._id:1}); db.col.ensureindex({aprent._id:1}); db.col.ensureindex({somrelation._id:1});
He should be able to start searching for the optimal indexes for your query.
I must emphasize that you need to verify this yourself.