【发布时间】:2012-12-17 10:36:23
【问题描述】:
我正在从集合中获取所有行,并在第 100 行遇到延迟。我知道 find 方法返回游标,并不是所有的数据都预先并且在某些时候需要获取更多数据。但是第 100 行是唯一的延迟。
Checking images 99
Checking image 100
*pause*
Checking image 101
然后在 100 000 张图像中没有可见的延迟。
使用 ruby 脚本:
require 'mongo'
time_start = Time.now
mongo = Mongo::MongoClient.new("localhost", 27017)
db = mongo["pics"]
images = db["images"]
albums = db["albums"]
orphans = []
images.find().each do |row|
puts "Checking image #{row['_id']}"
end
# puts orphans
time_end = Time.now
puts "Total time taken: #{time_end - time_start}"
mongoimport --db pics --collection images file_name
问题是:
- 初始光标是否有一些数据?
- 为什么只有第 100 行有延迟?也许我错过了一些东西,但那时我什至没有看到 IO 读取
谢谢
【问题讨论】:
标签: mongodb mongodb-ruby