I experience problems with query performance in Mongoid
.
The major part of time is taken by query plan but not query itself (the relation is 5-to-1) and this is not being changed after a number of requests.
https://www.mongodb.com/docs/manual/core/query-plans/
My expectations
DB
should not spend that much time on analyze phase. Imo it never should be a bottleneck – no matter how bad my indexes are.
I expect mongo to adjust itself after several requests but it’s not.
Details
The query I am talking about is on big collection with big skip
. Nevertheless I can see no reason why query plan
works that strange: it seems like DB
just not cache plan analyze results and perform it every request.
Environment:
rails
(7.0.8.1);mongo
(2.15.1);mongoid
(7.5.4).Mongo DB
(same problems on 3.4.15 and 4.4.10)
Questions
-
Why it continues to take that much time on query plan in every request?
-
Does
Mongoid
have query plan cache functionality at all? If so:
a) why am I experiencing suchDB
behaviour?
b) does it have anyAPI
and where can I find any docs describing that? E.g. is there any way I can configure query cache plan inMongoid
anyhow (check query plan cache or clear it)?
Thank you in advance!