Database Reference
In-Depth Information
Counter columns and deletion
Just as INSERT statements are not a useful operation on counter columns, neither are
DELETE statements. It is possible to delete a row containing counter columns:
DELETE FROM "daily_status_update_views"
WHERE "year" = 2014
AND "date" = '2014-02-01';
However, a counter column deletion is permanent: you can never put data back in the
counter in that row. Let's try re-adding some data to the row for February 1:
UPDATE "daily_status_update_views"
SET "total_views" = "total_views" + 100
WHERE "year" = 2014
AND "date" = '2014-02-01';
On reading the data in the table, we'll see something surprising:
The data we've just inserted isn't there. Cassandra reported no error when we tried to incre-
ment the counter; it just silently dropped the operation.
Because of the way counter columns handle deletions, it's inadvisable to ever issue a
DELETE statement against a counter column. Counters are great for aggregating values
that you will never need to reset or remove; as long as you only need to modify counters
via increments and decrements, they perform admirably. Aggregating user behavior is one
use case that precisely fits within this domain.
Search WWH ::




Custom Search