Index 1:
{
A: 1
}
Index 2:
{
B: 1
}
query:
db.col.aggregate([
{
$match: {
$or: [
A: { $eq: 100 },
B: { $eq: 100 },
]
}
}
])
Will mongodb use both indexes in this query?
Index 1:
{
A: 1
}
Index 2:
{
B: 1
}
query:
db.col.aggregate([
{
$match: {
$or: [
A: { $eq: 100 },
B: { $eq: 100 },
]
}
}
])
Will mongodb use both indexes in this query?
according to docs:
https://www.mongodb.com/docs/manual/reference/operator/query/or/
it will use both indexes.