0
私は解析されたデータをMongoDBに保存しようとしています。私はすべてのリファラーURLを保存したい。現在、MongoDBに挿入するのに多くの時間がかかります。MongoDBのデータ読み込み速度が遅いのはなぜですか?
class ReferrerDocument
include MongoMapper::Document
key :website_url, String
key :referrer_url, String
key :full_referrer_url, String
key :count_of_appearance, Integer, :default => 1
key :current_time, Time
timestamps!
def self.save_referrer_info(website_url, referrer_url, full_referrer_url, current_time)
referrer_document = ReferrerDocument.last(:website_url => website_url,
:referrer_url => referrer_url,
:order => :id.asc)
if(referrer_document.nil?)
ReferrerDocument.create(:website_url => website_url,
:referrer_url => referrer_url,
:full_referrer_url => full_referrer_url,
:last_seen_at => 0,
:current_time => current_time)
else
count = referrer_document.count_of_appearance += 1
last_seen_at = referrer_document.current_time.utc
ReferrerDocument.create(:website_url => website_url,
:referrer_url => referrer_url,
:full_referrer_url => full_referrer_url,
:last_seen_at => last_seen_at,
:current_time => current_time,
:count_of_appearance => count)
end
end
end