简体   繁体   中英

MongoDB Query Performance Analysis

I have done a reasonable amount of searching about getting information on slow queries, but the information I've found seems to indicate that the data you can get out of the db is rather limited.

I would like to know for a query how much time is spent waiting on locks, which index was used for the query, how much time was spent waiting/getting from disk, and how much time was spent processing (of particular interest for aggregation framework performance).

I wanted to check and see if people here had any suggestions for measuring these parameters, and/or if it was even possible.

Thanks in advance. :)

*Edit. I tend to use the java mongo driver, if that matters.

There is something that may not be obvious if you haven't looked into mongod logs - all operations that take longer than "slow ms" threshold (100ms is the default but you can change it) are logged into mongod log file.

Here is an example of what it might look like and how to read it:

update training.scores query: { score: { $lte: 90.0 } } update: { $set: { grade: "B" } } nscanned:4876 nmoved:2438 nupdated:2438 keyUpdates:0 numYields: 2 locks(micros) w:400877 235ms

You can see what some of these fields mean here , but the ones you are interested in are locks, numYields, nmoved and nupdated as well as nscanned - also scanAndOrder (that's whether a sort used an index or had to be done in memory).

I recommend reviewing that docs page about what information you can get from the system.profile collection and also from the mongod logs to help in investigating performance of your cluster.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM