通过设置profile来分析哪些操作时慢查询。

注:要操作的数据库记得设置好权限,要有dbAdmin权限才能操作profile, 比如:user game db.createUser({user: “game”, pwd: “123456”, roles: [ “readWrite”, “dbAdmin” ]})

测试环境在mongodb 4, 通过控制台,db.setProfilingLevel不成功,无论是通过mongos还是mongod都不成功,最后只能通过配置文件,–profile=1 --slowms=200,在启动时加载,生效。

测试结果:

不正常的全表扫描

mongodb慢查询分析解决

正常的带索引的扫描

mongodb慢查询分析解决

参考文章:https://blog.csdn.net/yisun123456/article/details/78274477
https://blog.csdn.net/u013451157/article/details/78765784

相关文章:

  • 2022-12-23
  • 2021-11-09
  • 2022-12-23
  • 2021-07-28
  • 2022-03-08
  • 2022-01-22
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 1970-01-01
  • 2021-06-21
  • 2022-02-13
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案