> --
> You received this message because you are subscribed to the Google Groups "mongodb-user" group.
> To post to this group, send email to mongod...@googlegroups.com.
> To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
>
>
AdvancedDatastore ads = ...;
ads.insert(listOfEntities);
Yes, batching does speed things up. Doing this in parallel, in
multiple threads, can help too; there is considerable time (cpu) spent
in preparing each batch into binaries packets to send to the server.
Using the morphia insert method does bulk inserts in the driver; so it
is up to you how much code you want to write.
> And if there were considerable time saving using parallelized inserts,
> I would think that the right place to do it will be in mongo java
> driver and not in morphia.
I would do it at the top level, in your application, on top of
morphia; you can do either but at the driver it will require you
writing more code.
So, morphia already does batch inserts, the same as the driver...
since it just calls the driver.
To break up the inserts into parallel batches (using multiple threads)
you would have to do that in your app. I don't think the driver or
morphia has that kind of feature on the (short) list. Although, doing
this on reads (queries) would really have to happen in the driver, and
across multiple threads.
http://code.google.com/p/morphia/source/browse/trunk/morphia/src/test/java/com/google/code/morphia/TestPerf.java#311
http://code.google.com/p/morphia/source/browse/trunk/morphia/src/test/java/com/google/code/morphia/TestPerf.java#325
On Mon, Feb 6, 2012 at 3:31 PM, Hung Lin <hun...@gmail.com> wrote:
> Hi Scott,
>
> I read the code from the link you posted, the batch mode is a loop to
> insert one by one:
>
> for (DBObject doc : batchPush)
> c.insert(doc);
>
> So, can I say as the mongodb server still receives each insert command
> one by one, therefore, it not really a batch operation as mongodb
> server per se. Please correct me if I'm wrong. Thanks for your time.
>
>
>
>
> Best,
> Hung
>
>
> On Feb 7 2011, 9:40 am, Scott Hernandez <scotthernan...@gmail.com>
> wrote:
>> There is no need to write all that code. Morphia (Advanced)Datastore
>> has a batch insert method:
>>
>> AdvancedDatastore ads = ...;
>> ads.insert(listOfEntities);
>>
>> http://code.google.com/p/morphia/source/browse/trunk/morphia/src/test...