简体   繁体   English

MongoDB第一次查询慢

[英]MongoDB first query slow

I'm getting really weird behaviour from mongodb. 我从mongodb得到了非常奇怪的行为。

I have a sharded session tracking collection were i do findOne's only on the _id (=shard key). 我有一个分片会话跟踪集合,我只在_id(=分片键)上找到findOne。

Before getting the session data I get the site data (non sharded collection) also with findOne (also on the _id), I cache the site data in memcached, this way the tracking findOne takes about 0.04 seconds to fetch. 在获取会话数据之前,我还使用findOne(也在_id上)获取了站点数据(非分片集合),我将该站点数据缓存在memcached中,这样,跟踪findOne大约需要0.04秒来获取。

However when I disable memcached on the site data and force it to get the data from mongodb the tracking findOne takes 0.001 seconds and the site findOne now is slow. 但是,当我在站点数据上禁用memcached并强制其从mongodb获取数据时,跟踪findOne需要0.001秒,而站点findOne现在很慢。

Explain situation 2 with findOne site first: http://pastebin.com/qTX0az7H 首先使用findOne网站解释情况2: http//pastebin.com/qTX0az7H

Explain situation 1 with findOne tracking first: http://pastebin.com/bBSXUEKh 首先跟踪findOne来解释情况1: http//pastebin.com/bBSXUEKh

I'm using the PHP driver 1.4.4 and mongodb version v2.4.6 我正在使用PHP驱动程序1.4.4和mongodb版本v2.4.6

显然,这是由于使用php中的Mongo类而不是MongoClient类进行连接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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