Skip to content

Merges on a table with TTL leave empty partitions #5491

@SaltTan

Description

@SaltTan

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 │
└───────────┴────────────┴────────┴──────┘

Metadata

Metadata

Assignees

Labels

comp-ttlTTL rules and TTL merges (moving/recompressing/rolling-up/deleting parts).

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions