> 데이터 베이스 > MySQL 튜토리얼 > MongoDB Tip: The touch Command

MongoDB Tip: The touch Command

WBOY
풀어 주다: 2016-06-07 16:29:45
원래의
989명이 탐색했습니다.

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으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿