-
Type: Improvement
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
-
Environment:JRuby 1.7.20 (1.9 mode), MongoDB 2.4
Hi,
We just upgraded our ruby driver from 1.3.1 to 2.0.6 in our production environment and we noticed significant increase in query response times for some of our core API's. After debugging, we noticed that the response times were slow due to the 'deserialization' of the BSON::Documents in the Ruby Driver.
def self.deserialize(io) deserialize_header(io) message = allocate fields.each do |field| if field[:multi] deserialize_array(message, io, field) else deserialize_field(message, io, field) end end message end
local_1:PRIMARY> db.embedded_docs.findOne() { "_id" : 485, "name" : "embedded-485", "uat" : ISODate("2015-08-31T22:41:19.609Z"), "tp" : "embedded", "ct" : 485, "refs" : [ { "_id" : 0, "n" : "embed-0", "v" : 0 }, { "_id" : 1, "n" : "embed-1", "v" : 1 }, .... ] }
e.g. we ran 2 queries to return 100 documents - first without the 'refs' array and then with the 'refs' array (100 elements).
Driver 2.0.6:
Query 1: 9ms
Query 2: 190ms <-- slow!!
Driver 1.3.1:
Query 1: 15ms
Query 2: 35ms
Please review and let me know if you need more info. Thanks!