DataStax Academy FAQ

DataStax Academy migrated to a new learning management system (LMS) in July 2020. We are also moving to a new Cassandra Certification process so there are changes to exam bookings, voucher system and issuing of certificates.

Check out the Academy FAQ pages for answers to your questions:


question

mayurajoundal_194027 avatar image
mayurajoundal_194027 asked ·

What is a more efficient way to insert multiple partitions with spring-data-cassandra?

Hi ,

What is efficient way to insert multiple rows in cassandra db from java.

I am using spring-data and it took 2 minutes to insert 600 rows

spring-data-cassandra
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

Tomasz Lelek avatar image
Tomasz Lelek answered ·

Hello,

The bottleneck of inserting these 600 rows maybe not Spring Data Cassandra, but spring boot.
If your Cassandra code is used from the spring boot and invoked via HTTP, you may want to consider increasing the number of threads in spring (thread pool)

Regarding Spring-Data-Cassandra and possible performance improvements:

1. If you are using CqlTemplate, consider reworking your logic to async version: AsyncCqlTemplate, or reactive: ReactiveCqlTemplate

2. Leverage PrerparedStatement (instead of SimpleStatement) and use it in subsequent queries to reduce overhead when sending each query

3. Use BatchStatement to batch N statements that will be sent as a one batch request.



Share
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.