I've noticed that performance of inserts for very big documents (in terms of number of objects in the document's tree) seemed to be very poor, and that the majority of the time was spent in the client.
So I ran a quick test to see how many time the `to_bson` method gets called per insert, and the answer is 6, which frankly seems to be quite too many.
This is my simple test:
class A def initialize @a = [1, 2, 3] end def bson_type @a.bson_type end def to_bson(*args) puts "to_bson" @a.to_bson(*args) end end MyCollection.collection.insert_one({ary: A.new})
This is the output:
to_bson to_bson to_bson to_bson to_bson to_bson
I see there already is this bug https://jira.mongodb.org/browse/RUBY-2335 that's supposed to handle one case of redundant serialization connected with compression.
- is related to
-
RUBY-2335 Improve compression performance
- Backlog
- links to