0 | I am having the document structure below. Here one user holds multiple documents with different continent and country combination array. The country code is of any dataType. I need to fetch the single document for the single user with complete matching the countryarray.
The below query i tried to execute it.
The below is how i indexed my document.
With this structure and combination , when i do multiple find with create or update the the execution time is very slow.Can anyone help me how i improve my execution speed. |
db.data.find({ "$or": [{"user": "Alpha", "continent": "XXXX", "country.countryName": "AAA" }, {"user": "Alpha", "continent": "XXXX", "country_code": "123"}] });
db.data.createIndex({"user" : 1, "continent" : 1, "country.countryName" : 1});
db.data.createIndex({"user" : 1, "continent" : 1, "country.country_code" : 1});