Closed matteosist closed 3 years ago
Is it possible to share a unit test / project with the issue reproduced? If not, please share the below details too, I will try to reproduce it from my side.
Can you share the below index creation code too?
I have a simple unit test, which includes five indexes, and couple of joins which is always returning the same explain for the query. Also how often are you seeing the change?
@matteosist If you are still facing the issue, could you please check and provide the requested information?
Closing for now, in case you are still facing the issue feel free to reopen the issue with requested details.
Describe the bug Hi, i've an application with about 500k documents and i have many complex queries, so queries optimization with properly indexes is mandatory.
I don't know if i'm creating indexes in the right way but in this moment with this indexes i've sufficient performances for my use case. I want to take a single query as example but this issue is present to all queries randomly.
I have the following query:
Without indexes (i mean only with single index on "type" field with name "TypeIndex") this query takes from 30 to 90 seconds to return result (based on device performance).
So i create this index with name "ActivitiesIndexWithWhere":
Of course i have more other indexes. If are needed i can provide to you.
With this index the query takes from 0.05 to 3 second to return result (acceptable).
I know that maybe i can improve the performance but can be enough for me. But randomly, after create the index, query takes more than 30 seconds to return result without any reason. If i delete the app and then i reinstall again, all works perfectly. No changes happens on dataset or queries or indexes.
So i try to debug for many times until i tried to run "explain()" function on query before run the query between two consecutive re-installations and i get two different results.
In the first case i get this explanation (and in this case i get the result in 0.1 sec):
In the second case i get this explanation (and query takes 30 seconds):
What i'm doing wrong? Why i get different results? And why same query, with same dataset, use different indexes? I saw that in the query explanation there are more indexes used and not only "ActivitiesIndexWithWhere". So maybe i need to create indexes in another way, but which way? I'm not able to found exhaustive documentation on this topic.
Platform (please complete the following information):
Many thanks.