Hangfire.Mongo: Slow operations reported by Atlas
Using Hangfire.Mongo v1.9.14 in production, on a Mongo Atlas M40 cluster.
The Atlas Profiler reports a lot of slow operations for the jobGraph collection (5-6 seconds to complete):
Most of those slow operations are reported for this query:
"find": "Contents.jobGraph",
"filter": {
"_t": "ListDto"
},
"projection": {
"_id": 1
},
Which in my case returns 227k documents.
An explain on this query shows:
I believe that this long query is invoked by this code:
The enclosing method, TrimList(), has a key argument which is not used as a predicate in the Mongo query, but rather as a Where clause in a code manipulation of the returned list.
I wonder if refactoring the code to include the key in the Mongo query would help?
About this issue
- Original URL
- State: open
- Created 7 months ago
- Comments: 20 (20 by maintainers)
Commits related to this issue
- optimize trimming list and show retry info in dashboard fix Dashboard does not show exception for retries (#375) fix Slow operations reported by Atlas (#374) — committed to Hangfire-Mongo/Hangfire.Mongo by gottscj 7 months ago
- optimize trimming list and show retry info in dashboard (#376) * optimize trimming list and show retry info in dashboard fix Dashboard does not show exception for retries (#375) fix Slow operatio... — committed to Hangfire-Mongo/Hangfire.Mongo by gottscj 7 months ago
@gottscj Nice find! Then make sure to have an index on
_t, key, _id