我已经设置了一个couchdb
数据库,用于使用couchrestruby on rails
的应用程序。
现在数据库有大约 10 万条记录,我想添加一个字段来以整数格式存储时间戳。
尝试通过循环更新它会导致请求超时。
向 couchdb 添加新字段/属性的最佳方法是什么?
代码
pages = Page.all
pages.each do |p|
p.update_attributes(:created_at_to_i => p.created_at.to_i)
puts p.created_at_to_i.inspect
end
痕迹
>> Page.update_timestamp
RestClient::RequestTimeout: Request Timeout
from /usr/local/lib/ruby/gems/1.8/gems/rest-client-1.6.7/lib/restclient/request.rb:184:in `transmit'
from /usr/local/lib/ruby/gems/1.8/gems/rest-client-1.6.7/lib/restclient/request.rb:64:in `execute'
from /usr/local/lib/ruby/gems/1.8/gems/rest-client-1.6.7/lib/restclient/request.rb:33:in `execute'
from /usr/local/lib/ruby/gems/1.8/gems/couchrest-1.1.2/lib/couchrest/rest_api.rb:89:in `execute'
from /usr/local/lib/ruby/gems/1.8/gems/couchrest-1.1.2/lib/couchrest/rest_api.rb:45:in `get'
from /usr/local/lib/ruby/gems/1.8/gems/couchrest-1.1.2/lib/couchrest/database.rb:260:in `view'
from /usr/local/lib/ruby/gems/1.8/gems/couchrest-1.1.2/lib/couchrest/design.rb:52:in `view_on'
from /usr/local/lib/ruby/gems/1.8/gems/couchrest_model-1.1.2/lib/couchrest/model/views.rb:142:in `fetch_view'
from /usr/local/lib/ruby/gems/1.8/gems/couchrest_model-1.1.2/lib/couchrest/model/views.rb:135:in `fetch_view_with_docs'
from /usr/local/lib/ruby/gems/1.8/gems/couchrest_model-1.1.2/lib/couchrest/model/views.rb:104:in `view'
from /usr/local/lib/ruby/gems/1.8/gems/couchrest_model-1.1.2/lib/couchrest/model/document_queries.rb:12:in `all'
from /var/www/monitoring_couch/app/models/page.rb:309:in `update_timestamp'
from (irb):2