Imagine that you have a collection with info about goods in an antique store. Each document has the following structure:
{
"id": 100,
"category": "furniture",
"price":1000,
"quantity": 10
}
You've created this index:
db.goods.createIndex({price: 1, quantity: 1})
And performed the following request:
db.goods.find({quantity: {$gte: 2}, price: {$lt: 1000}}, {quantity: 1, id: 0})
How the following query will be executed?
Here are the options:
No index will be used, all results will be retrieved directly from the DB.
Index will be used and after that results will be retrieved from the DB.
The desired results will be retrieved only from the index.
Index will be used and after that results will be retrieved from the cache.