If I have a collection with the following schema:
{
"author": …,
"title": …,
"pages": …,
"publishDate": …,
}
where author and title are a part of a compound index.
I want to find all documents whose author and title might be one of the following:
"Melville", "Moby Dick"
"Orwell", "1984"
"Tolkien", "The Hobbit"
How can I do it using the "$in" statement? I could do it with "$or" but the performance is disastrous.
$oris how you do this, so if the performance using that is bad, your compound index is likely not being used. Have you check it withexplain()?$or. What are you trying to do? Maybe there's another way to approach this.$instatement. But it's a legacy system and that pair of fields is the only unique identifier in the collection. I could use the_idfield because it's indexed but it may introduce subtle imprecisions because it's not a business identifier. I just wanted to find out if there's such an$instatement that might solve my problem