doanduyhai / Achilles

An advanced Java Object Mapper/Query DSL generator for Cassandra
http://achilles.archinnov.info
Apache License 2.0
241 stars 92 forks source link

Bulk Insert/Update Operation #379

Open payalmujavadiya opened 3 years ago

payalmujavadiya commented 3 years ago

Please support for bulk insert and update queries at once

payalmujavadiya commented 3 years ago

We are using achilles in our application where we were using insert/update for single entity till now using crud().insert(entity).execute() is there any way we can insert List of entities and execute it at once ?, just to save db calls

doanduyhai commented 3 years ago

In Cassandra CQL, there is no efficient way to batch multiple statements together.

Indeed there is a BATCH CQL command but it will just put the stress on the coordinator node. You'll not see any perf improvement with BATCH statement. The only scenario where BATCH statement is really faster is when all your insert statements belong to the same partition key

If it's the case, have a look at Batch Mode in Achilles

Otherwise, it'll be faster for you to loop through a list of insert statements and use the async API to make the inserts queries parallel.

Be careful when using async feature, do not forget to put a reasonable pause between async inserts otherwise you'll overwhelm the server