Hello, DataStax Community!

We want to make you aware of a few operational updates which will be carried out on the site. We are working hard to streamline the login process to integrate with other DataStax resources. As such, you will soon be prompted to update your password. Please note that your username will remain the same.

As we work to improve your user experience, please be aware that login to the DataStax Community will be unavailable for a few hours on:

  • Wednesday, July 15 16:00 PDT | 19:00 EDT | 20:00 BRT
  • Thursday, July 16 00:00 BST | 01:00 CEST | 04:30 IST | 07:00 CST | 09:00 AEST

For more info, check out the FAQ page. Thank you for being a valued member of our community.


Barnesicle avatar image
Barnesicle asked ·

Nested collections and types

I am wondering if I should be wary of using types with collections or collections in general. I did read somewhere that it is recommended not to even use collections at all but instead to use multiple columns with denormalized data. Is this true for later Cassandra versions as well?

If it is ok to use collections is there a point where it can be a concern? Like field size?

Small example:

name text

id text,
name text,
max_quantity int,
options list<FROZEN<option>>,
created timestamp,
last_updated timestamp

id text,
name text,
description text,
email text,
categories set<text>,
end_date timestamp,
created timestamp,
last_updated timestamp,
owner_id text,
accepted boolean,
role text,
first_nested list<FROZEN<nested1>>,
PRIMARY KEY ((id), email)

UPDATE: If you don't mind I would like to also expand on my question. Is there a limit to the size of the lists? Or nested collections inside. In the example above, what if I had for example 100 records in the first_nested row? Or a collection on first_nested, what if I had another 100 records on that? Collections greatly simplify query patterns but I am worried that it will cause issues in the future.

1 comment
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.

@Barnesicle apologies for the delayed response. I thought I had already answered this last night.

0 Likes 0 · ·

1 Answer

Erick Ramirez avatar image
Erick Ramirez answered ·

@Barnesicle you are right in that you should store data in multiple columns if it suits your use case/data model. But if you really need UDTs, then you should use them. Just be aware of the cons such as an entire frozen list must be read so its size may affect performance; individual fields in a frozen collection cannot be updated; and you can't remove fields in a UDT. Cheers!

2 comments 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.

I added an extra question at the end if you don't mind.

1 Like 1 · ·

@Barnesicle in theory lists can have up to 64K (2^16) items. See Creating Collections for details. Cheers!

0 Likes 0 · ·