Reputation: 1907
I need populate 4 different tables in cassandra, by absolutely same data.
I mean, I have N fields, each has some value, but I need store them in 4 different tables (with different PK definitions) to allow different selects.
For that I need trigger 4 inserts.
4 times more network overhead and work for both cassandra and data producer.
Is there way in cassandra to send 1-ce and save in N different tables?
I need some optimization, but batches are not looking appropriate for that.
Please, help!!
Upvotes: 0
Views: 39
Reputation: 2076
Cassandra triggers could also work for you. You create a trigger Java class and deploy it in a Jar to each node. When it intercepts your main table insert, it also tacks on writes to the others.
Upvotes: 1
Reputation: 1661
If you don't want to use batch inserts, and you have the chance to use Cassandra 3.x you can use a new feature Materialized Views. With materialized views you can basically do exactly what you asked for. You will have to create one main table where you do all your inserts on. Then you would have to create 3 materialized views.
When you insert data into your main table, all your views will be updated by cassandra. Internally cassandra will also do those inserts, so the traffic overhead is still there (only starting on the coordinator and not on your client)
Note that those new features are not for free. As I said, there will be overhead traffic and work to be done by the coordinator. Currently there are only simple select statements possible, more complex queries are not working right now.
The provided link gives more insights of how these views work, so please have an additional look there.
Upvotes: 0