-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Merges on a table with TTL leave empty partitions #5491
Copy link
Copy link
Closed
Labels
comp-ttlTTL rules and TTL merges (moving/recompressing/rolling-up/deleting parts).TTL rules and TTL merges (moving/recompressing/rolling-up/deleting parts).
Description
It's possible that after a merge on a table with TTL there will be no more rows in some partitions. It makes sense to drop those partitions.
drop table if exists ttl_00933_1;
create table ttl_00933_1 (d Date, a Int) engine = MergeTree order by a partition by toYear(d) ttl d + interval 1 day;
insert into ttl_00933_1 values (toDate('2000-10-10'), 1);
insert into ttl_00933_1 values (toDate('2100-10-10'), 2);
optimize table ttl_00933_1 final;
select partition, name, active, rows from system.parts where table = 'ttl_00933_1' and active
SELECT
partition,
name,
active,
rows
FROM system.parts
WHERE (table = 'ttl_00933_1') AND active
┌─partition─┬─name───────┬─active─┬─rows─┐
│ 2000 │ 2000_1_1_1 │ 1 │ 0 │
│ 2100 │ 2100_2_2_0 │ 1 │ 1 │
└───────────┴────────────┴────────┴──────┘
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
comp-ttlTTL rules and TTL merges (moving/recompressing/rolling-up/deleting parts).TTL rules and TTL merges (moving/recompressing/rolling-up/deleting parts).