i confused 2 seemingly contradictory statements cassandra
- no reads before writes (presumably because writes sequential whereas reads require scanning primary key index)
- insert , update have identical semantics (stated in older version of cql manual presumably still considered true)
suppose i've created following simple table:
create table data ( id varchar primary key, names set<text> );
now insert values:
insert data (id, names) values ('123', {'joe', 'john'});
now if update:
update data set names = names + {'mary'} id = '123';
the results expected:
id | names -----+------------------------- 123 | {'joe', 'john', 'mary'}
isn't case read has occur before write? "cost" seem the following
- the cost of reading column
- the cost of creating union of 2 sets (negligible here noticeable larger sets)
- the cost of writing data key , new column data
an insert merely doing last of these.
there no need read before writing.
internally each collection stores data using 1 column per entry -- when ask new entry in collection operation done in single column*: if column exists overwritten otherwise created (insertorupdate
). reason why each entry in collection can have custom ttl , writetime.
*while map
, set
transparent there internal trick allow multiple columns same name inside list
.