How to multi insert rows in cassandra

前端 未结 5 2352
北海茫月
北海茫月 2021-02-18 23:29

What is the most efficient way of inserting multiple rows in cassandra column family. Is it possible to do this in a single call.

Right now my approach is to addinsert m

5条回答
  •  一整个雨季
    2021-02-19 00:19

    When trying to insert multiple rows. Database connection RTT could be the performance bottle neck. In that case, we generally need a way to avoid waiting for one INSERT to finish so that we can begin our next INSERT.Currently there are two ways as far as I know:

    • If data consistency matters, use LOGGED BATCH, but as this question said, BATCH may not have a performance boost in all the situation.
    • Otherwise, use a async api in the Cassandra client library, for example in python there is a execute_async method

    Also, you can prepare the SQL statement before execute it. I haven't test the overall performance of a prepared statement vs plain insert. But I think if there are thousands INSERT or more you should get a performance boost.

提交回复
热议问题