rox
rox

Reputation: 565

How Cassandra DateTieredCompactionStrategy identifies my data timestamp?

New to Cassandra, I just read the blog about Cassandra DTCS.

Supose I have a table like this for example,

CREATE TABLE foo (
   id text,
   t1 timestamp,
   t2 timestamp,
   bar text,
   PRIMARY KEY (id,t1)
);

Looks like the only thing I need to do to enable DTCS is

ALTER TABLE <table> WITH compaction = {
    'class': 'DateTieredCompactionStrategy',
    'timestamp_resolution':'<resolution>', 'base_time_seconds':'3600',
    'max_sstable_age_days':'365'};

Is that true? Then how dose cassandra know which field of my data is the timestamp I expect to be used for DTCS?

Upvotes: 2

Views: 227

Answers (1)

OrangeDog
OrangeDog

Reputation: 38787

It doesn't use the value of any of your "fields".

Every non-key column has an associated writetime, which is what the strategy uses.

This can be set manually with a USING TIMESTAMP clause, or will be set automatically to the time of the update/insert/delete.

Therefore, you may now find you don't actually need t2 in your schema, but can just use the writetime of bar.

Upvotes: 1

Related Questions