Skip to content

Improve performance of saving entities by using insert(…) if possible [DATAMONGO-1054] #1975

Closed
@spring-projects-issues

Description

@spring-projects-issues

Titi Wangsa opened DATAMONGO-1054 and commented

Mongo Template has this method:

void insert(Collection<? extends Object> batchToSave, Class<?> entityClass);

that does a bulk insert

Basic repository interfaces that extend from MongoRepository does not have it. They have:

<S extends T> List<S> save(Iterable<S> entites);

this is considerably much slower.

actual:
saving using
MongoRepository.save(Iterable<S> entites)
for 6,000+ items took a few minutes when write concern is set to journaled

expected
ability to save it in matter of milliseconds
by using
MongoOperation.insert(Collection<? extends Object> batchToSave, Class<?> entityClass);

workaround:
I created a CustomImpl that for my repository class that calls mongoOperation. this is much faster. I am hoping that it .insert would be a built-in feature on the next release


Attachments:

Issue Links:

  • DATAMONGO-903 Add insert method to MongoRepository interface
    ("supersedes")

Referenced from: pull request #253, and commits 2e74c19, 1b7e077, e58fa28, 7ebaf93, 714446b, a212b75, fa2c609

Backported to: 1.6.2 (Evans SR2)

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions