Clickhouse table TTL does not remove old records

2.1k Views Asked by At

I have added a TTL to this GraphiteMergeTree table, but old records are not being removed automatically.

CREATE TABLE default.graphite_data
(
    `Path` String,
    `Value` Float64,
    `Time` UInt32,
    `Date` Date,
    `Timestamp` UInt32
)
ENGINE = GraphiteMergeTree('graphite_rollup')
PARTITION BY toYYYYMM(Date)
ORDER BY (Path, Time)
TTL Date + toIntervalQuarter(2)
SETTINGS index_granularity = 8192

I still see old data in this table:

SELECT *
FROM graphite_data
LIMIT 10

┌─Path─────────────────────────────┬─Value─┬───────Time─┬───────Date─┬──Timestamp─┐
│ carbon.agents.test.pickle.active │     0 │ 1577833200 │ 2020-01-01 │ 1577836784 │
│ carbon.agents.test.pickle.active │     0 │ 1577836800 │ 2020-01-01 │ 1577840384 │
│ carbon.agents.test.pickle.active │     0 │ 1577840400 │ 2020-01-01 │ 1577843984 │
│ carbon.agents.test.pickle.active │     0 │ 1577844000 │ 2020-01-01 │ 1577847584 │
│ carbon.agents.test.pickle.active │     0 │ 1577847600 │ 2020-01-01 │ 1577851184 │
│ carbon.agents.test.pickle.active │     0 │ 1577851200 │ 2020-01-01 │ 1577854784 │
│ carbon.agents.test.pickle.active │     0 │ 1577854800 │ 2020-01-01 │ 1577858384 │
│ carbon.agents.test.pickle.active │     0 │ 1577858400 │ 2020-01-01 │ 1577861984 │
│ carbon.agents.test.pickle.active │     0 │ 1577862000 │ 2020-01-01 │ 1577865584 │
│ carbon.agents.test.pickle.active │     0 │ 1577865600 │ 2020-01-01 │ 1577869184 │
└──────────────────────────────────┴───────┴────────────┴────────────┴────────────┘

10 rows in set. Elapsed: 0.029 sec.

I also did OPTIMIZE FINAL, but the result is still the same. What could be wrong here?

1

There are 1 best solutions below

7
On BEST ANSWER

TTL is not immediate. It's eventual.

Try ALTER TABLE default.graphite_data MATERIALIZE TTL