如果你正在经历铁路的停电,并且能够收集数据(例如数据变化经常发生),我将利用resque 或,而不是铁路向客户倾斜。 或者,如果数据不能按顺序排列,则使用http://railscasts.com/episodes/222-rack-in-rails-3” rel=“nofollow” Rackhandler,如Sinatra和 Metal,以提出答复。
www.un.org/Depts/DGACM/index_spanish.htm 用于反映样本数据
我得以在3.0.9例铁路中操作以下代码,而Mongo为1.8.4例。 我正在使用Mongo 1.3.1, bson_ext 1.3.1,Webrick 1.3.1和Corr.1.9.2p180x64。 它没有时间,而是需要一些时间来装载。 我的Mongo DB样本有100k记录,没有索引。
before_filter :profile_start
after_filter :profile_end
def index
db = @conn[ sample-dbs ]
collection = db[ email-test ]
@final = []
@bs = collection.find({})
@bs.each do |a|
puts "dentro do bs.each"
@final << { :Email => a[ headers ][ to ], :At => a[ date ], :subject => a[ headers ][ subject ], :Type => a[ headers ][ status ], :Message_id => a[ headers ][ message_id ] }
end
render :json => @final
end
private
def profile_start
RubyProf.start
end
def profile_end
RubyProf::FlatPrinter.new(RubyProf.stop).print
end
A more efficient way to dump out the records would be
@bs = collection.find({}, {:fields => ["headers", "date"]})
@final = @bs.map{|a| {:Email => a[ headers ][ to ], :At => a[ date ], :subject => a[ headers ][ subject ], :Type => a[ headers ][ status ], :Message_id => a[ headers ][ message_id ] }}
render :json => @final
My data generator
100000.times do |i|
p i
@coll.insert({:date =>Time.now(),:headers => {"to"=>"me@foo.com", "subject"=>"meeeeeeeeee", "status" => "ffffffffffffffffff", "message_id" => "1234634673"}})
end