Search code examples
cassandracqlcql3user-defined-typesnosql

User-defined type on a map collection OR composite column?


Hi,

I tried to create my data model for Cassandra, but i'm wondering about the best practices. I use on my model a User-defined type on a map collection, but some forums talked about composite column, which can be more efficient.

There is my model example :

Create table Account.user (

id_user uuid primary key,
name text,
list_data map<text, frozen <data>>); //about 160 000 insert per day

Create TYPE Account.data (

data1 text,
data2 text);

For list_data row, about 160 000 "data" type will be insert each day on the map collection. Is it efficient to use User-defined type with a map collection ? Or do i need to find another way with composite column ?

Thank you :)


Solution

  • You should start by asking the following questions:

    1. how do I add new data to the User
    2. do I have to update a pair of list_data
    3. how do I access list_data?

    If you go through these answers, keep in mind the possible options (using clustering columns, using collections + UDTs), and some of their pros and cons (e.g. limit on the size of a list), you'll most probably get a good data model that you can start testing.