DBMS/Cassandra
Cassandra, how is data updated?
seungh0
2023. 3. 8. 21:37
반응형
How is data updated?
- Cassandra treats each new row as an upsert
- During a write, Cassandra adds each new row to the database without checking on where a duplicate record exists.
- This policy makes it possible that many versions of the same row many exist in the database.
Periodically, the rows stored in memory are streamed to disk into structures called SSTables. At certain intervals, Cassandra compacts smaller SSTables into larger SSTables.
- If Cassandra encounters two or more versions of the same row during this process.
- Cassandra only writes the most recent version to the new SSTable.
- After compaction, Cassandra drops the original SSTables, deleting the outdated rows.
Most Cassandra installations store replicas of each row on two or more nodes. Each node performs compaction independently. This means that even though out-of-date versions of a row have been droped from one node, they may still exist on another node.
This is why Cassandra performs another round of comparisons during a read process. When a client requests data with a particular primary key, Cassandra retrieves many versions of thre row from one or more replicas.
The version with the most recent timestamp is the only one returned to the client.
반응형