Slow Queries in MongoDB
-
Hi, we see increased numbers of these log entries in mongoDB
{"t":{"$date":"2024-10-09T09:30:16.143+02:00"},"s":"I", "c":"COMMAND", "id":51803, "ctx":"conn39","msg":"Slow query","attr":{"type":"command","ns":"nodebb.objects","command":{"find":"objects"," filter":{"_key":"topics:tid"},"sort":{"score":1},"projection":{"_id":0,"_key":0,"score":0},"skip":129000,"limit":500,"lsid":{"id":{"$uuid":"dedb7031-7a1d-4cc0-82ba-1a47d0d18b35"}},"$db":"nodebb"}," planSummary":"IXSCAN { _key: 1, score: -1 }","planningTimeMicros":123,"cursorid":669374630645032835,"keysExamined":129101,"docsExamined":101,"fromMultiPlanner":true,"replanned":true,"replanReason": "cached plan was less efficient than expected: expected trial execution to take 10001 reads but it took at least 100011 reads","nBatches":1,"numYields":244,"nreturned":101,"queryHash":"A3928A9F","p lanCacheKey":"ED34AECF","queryFramework":"sbe","reslen":2821,"locks":{"FeatureCompatibilityVersion":{"acquireCount":{"r":245}},"Global":{"acquireCount":{"r":245}}},"storage":{"data":{"bytesRead":21 6878,"timeReadingMicros":195}},"cpuNanos":224969561,"remote":"127.0.0.1:54830","protocol":"op_msg","durationMillis":224}}
What is the proper way to check if indexes are setup correctly?
We have left cache sizes in nodeBB as default so far - do they impact those kind of issues?
I see Post Cache Hit Ratio only at 25%.
I assume increasing the post cache size has effect on mem needed for the node process?Thanks
SK -
i told @big_steve, that this community was always very helpful to us while migrating our basketball related online discussion site (32,098 registered users, 2,717,824 posts in 135,032 threads, voluntary driven) from custom made to nodeBB some years ago. he joined our admin-team because of some really annoying performance issues. it would be great if some of you @nodebb-development could help him getting a basic understanding of how to optimize our setup for better performance. thanks.
-
You should take a look at the cpu usage on your server, if it's high look into moving your database to another server and use more than one process for nodebb. It also helps to use redis for sessions so mongodb doesn't have to deal with that. https://docs.nodebb.org/configuring/scaling/