I am planning to use a Java object as a custom type and store it Cassandra. I am taking out 2 data members from the class and making them into primary key and keeping the rest of the data members in the custom type.
data members of my class: name, date_of_birth, occupation, last_visit, family_members, total_income
primary key: name, date_of_birth
cassandra custom type members: occupation, last_visit, family_members, total_income
Will the custom data type have any performance benefits while writing or reading when compared to storing the individual data members in terms of Cassandra data types.
Duration columns cannot be used in a table's PRIMARY KEY . This limitation is due to the fact that durations cannot be ordered.
Apache Cassandra supports the Cassandra Query Language, or CQL. Apache Cassandra Data Types are the classifications of data that indicate what type of data can be stored in a variable or object.
User-Defined Types (UDTs) can be used to attach multiple data fields to a column. User-defined types (UDTs) can attach multiple data fields, each named and typed, to a single column. The fields used to create a UDT may be any valid data type, including collections and other existing UDTs.
Will the custom data type have any performance benefits while writing or reading when compared to storing the individual data members in terms of Cassandra data types.
Not really. Data for user defined types (UDTs) is stored in a single column in the row, and that should be a faster read than multiple individual columns. But whatever performance gain you achieve there will quickly be erased as the data is serialized for the result set. While CQL will allow you to read individual fields of the UDT if you desire, Cassandra still has to read all contents of that column regardless.
It is important to note that user defined types are not about improving performance. They're about offering the flexibility to achieve small amounts of denormalization.
And just a suggestion, but perhaps it makes more sense to have members
as a collection, with each item containing data for each family member?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With