首页 > 数据库 > mysql教程 > MongoDB Tip: The touch Command

MongoDB Tip: The touch Command

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
发布: 2016-06-07 16:29:45
原创
996 人浏览过

MongoDB 2.2 introduced the touch command, which loads data from the data storage layer into memory. The touch command will load a collection’s documents, indexes or both into memory. This can be ideal to preheat a newly started server, in

MongoDB 2.2 introduced the touch command, which loads data from the data storage layer into memory. The touch command will load a collection’s documents, indexes or both into memory. This can be ideal to preheat a newly started server, in order to avoid page faults and slow performance once the server is brought into production. You can also use this when adding a new secondary to an existing replica set to ensure speedy subsequent reads.

Note that while the touch command is running, a replica set member will enter into a RECOVERING state to prevent reads from clients. When the operation completes, the secondary will return to the SECONDARY(2) state.

You invoke the touch command through the following syntax:

db.runcommand({ touch: “collection_name”, data: true, index: true})
登录后复制


Here you indicate which collection to touch and whether or not you want both documents (data) and/or indexes to be loaded into memory. Index and data are both off by default, so you will need to indicate at least one as “true” to have any effect on your server. Otherwise you will see the following message:

db.test.runCommand(“touch”)
 ???????"ok" : 0,
 ???????"errmsg" : "must specify at least one of (data:true, index:true)
登录后复制

touch is non-blocking on a mongod process, so you can run it concurrent with other commands.


For a full list of MongoDB commands, check out the Database commands in the MongoDB Manual

相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
mongodb启动
来自于 1970-01-01 08:00:00
0
0
0
linux - ubuntu14安装mongodb出错
来自于 1970-01-01 08:00:00
0
0
0
symfony2 mongodb的使用
来自于 1970-01-01 08:00:00
0
0
0
mac上配置mongodb 错误
来自于 1970-01-01 08:00:00
0
0
0
mongodb的参数理解
来自于 1970-01-01 08:00:00
0
0
0
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板