Database Reference
In-Depth Information
@col = @db['test.bulk.insert']
@ids = @col.insert(docs)
puts "Here are the ids from the bulk insert: #{@ids.inspect}"
Instead of returning a single object ID , a bulk insert returns an array with the object
ID s of all documents inserted. Users commonly ask what the ideal bulk insert size is,
but the answer to this is dependent on too many factors to respond concretely, and
the ideal number can range from 10 to 200. Benchmarking will be the best counsel in
this case. The only limitation imposed by the database here is a 16 MB cap on any one
insert operation. Experience shows that the most efficient bulk inserts will fall well
below this limit.
4.4
Summary
We've covered a lot of ground in this chapter; congratulations for making it this far!
We began with a theoretical discussion of schema design and then proceeded to
outline the data model for an e-commerce application. This gave you a chance to see
what documents might look like in a production system, and it should've gotten you
thinking in a more concrete way about the differences between schemas in RDMBS s
and MongoDB.
We ended the chapter with a harder look at databases, documents, and collections;
you may return to this section later on for reference. I've explained the rudiments of
MongoDB, but we haven't really started moving data around. That'll all change in the
next chapter, where we explore the power of ad hoc queries.
Search WWH ::




Custom Search