MongoDB 优化器profile

来源:互联网 发布:mac 安装websphere 编辑:程序博客网 时间:2024/06/05 02:02
1、概述

Mongodb profiling是Mngodb提供的类似于mysql的慢查询的功能,用于记录执行时间超过多少的语句,默认记录在system.profile中。

2、开启profiling功能

通过客户端开启

profile级别有三种:

0:不开启

1:记录慢命令,默认为大于100ms

2:记录所有命令

3、查询profiling记录

> db.system.profile.find();{ "ts" : ISODate("2014-05-05T02:45:10.359Z"), "info" : "query test.system.profile reslen:36 nscanned:0  \nquery: {}  nreturned:0 bytes:20", "millis" : 0 }{ "ts" : ISODate("2014-05-05T02:45:13.562Z"), "info" : "query test.$cmd ntoreturn:1 command: { count: \"system.profile\", query: {}, fields: {} } reslen:64 bytes:48", "millis" : 0 }{ "ts" : ISODate("2014-05-05T02:45:13.562Z"), "info" : "query test.system.profile ntoreturn:5 reslen:36 nscanned:2  \nquery: { query: { millis: { $gt: 0.0 } }, orderby: { $natural: -1.0 } }  nreturned:0 bytes:20", "millis" : 0 }{ "ts" : ISODate("2014-05-05T02:45:17.171Z"), "info" : "query test.emp reslen:261 nscanned:5  \nquery: {}  nreturned:5 bytes:245", "millis" : 0 }
说明:

ts:该命令执行的时间。

info:本命令的详细信息。

reslen:返回结果集的大小。

nscanned:本次查询扫描的记录数。

nretured:本次查询时间返回的结果集。

millis:该命令执行的耗时。

0 0
原创粉丝点击