mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-27 10:02:01 +00:00
Merge pull request #35953 from azat/ttl-mutations
Require mutations for per-table TTL only when it had been changed
This commit is contained in:
commit
fcb83a12ff
@ -818,22 +818,27 @@ bool AlterCommand::isCommentAlter() const
|
|||||||
bool AlterCommand::isTTLAlter(const StorageInMemoryMetadata & metadata) const
|
bool AlterCommand::isTTLAlter(const StorageInMemoryMetadata & metadata) const
|
||||||
{
|
{
|
||||||
if (type == MODIFY_TTL)
|
if (type == MODIFY_TTL)
|
||||||
|
{
|
||||||
|
if (!metadata.table_ttl.definition_ast)
|
||||||
return true;
|
return true;
|
||||||
|
/// If TTL had not been changed, do not require mutations
|
||||||
|
return queryToString(metadata.table_ttl.definition_ast) != queryToString(ttl);
|
||||||
|
}
|
||||||
|
|
||||||
if (!ttl || type != MODIFY_COLUMN)
|
if (!ttl || type != MODIFY_COLUMN)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
bool ttl_changed = true;
|
bool column_ttl_changed = true;
|
||||||
for (const auto & [name, ttl_ast] : metadata.columns.getColumnTTLs())
|
for (const auto & [name, ttl_ast] : metadata.columns.getColumnTTLs())
|
||||||
{
|
{
|
||||||
if (name == column_name && queryToString(*ttl) == queryToString(*ttl_ast))
|
if (name == column_name && queryToString(*ttl) == queryToString(*ttl_ast))
|
||||||
{
|
{
|
||||||
ttl_changed = false;
|
column_ttl_changed = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ttl_changed;
|
return column_ttl_changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AlterCommand::isRemovingProperty() const
|
bool AlterCommand::isRemovingProperty() const
|
||||||
|
@ -0,0 +1,22 @@
|
|||||||
|
-- { echoOn }
|
||||||
|
alter table per_table_ttl_02265 modify TTL date + interval 1 month;
|
||||||
|
select count() from system.mutations where database = currentDatabase() and table = 'per_table_ttl_02265';
|
||||||
|
1
|
||||||
|
alter table per_table_ttl_02265 modify TTL date + interval 1 month;
|
||||||
|
select count() from system.mutations where database = currentDatabase() and table = 'per_table_ttl_02265';
|
||||||
|
1
|
||||||
|
alter table per_table_ttl_02265 modify TTL date + interval 2 month;
|
||||||
|
select count() from system.mutations where database = currentDatabase() and table = 'per_table_ttl_02265';
|
||||||
|
2
|
||||||
|
alter table per_table_ttl_02265 modify TTL date + interval 2 month group by key set value = argMax(value, date);
|
||||||
|
select count() from system.mutations where database = currentDatabase() and table = 'per_table_ttl_02265';
|
||||||
|
3
|
||||||
|
alter table per_table_ttl_02265 modify TTL date + interval 2 month group by key set value = argMax(value, date);
|
||||||
|
select count() from system.mutations where database = currentDatabase() and table = 'per_table_ttl_02265';
|
||||||
|
3
|
||||||
|
alter table per_table_ttl_02265 modify TTL date + interval 2 month recompress codec(ZSTD(17));
|
||||||
|
select count() from system.mutations where database = currentDatabase() and table = 'per_table_ttl_02265';
|
||||||
|
4
|
||||||
|
alter table per_table_ttl_02265 modify TTL date + interval 2 month recompress codec(ZSTD(17));
|
||||||
|
select count() from system.mutations where database = currentDatabase() and table = 'per_table_ttl_02265';
|
||||||
|
4
|
@ -0,0 +1,22 @@
|
|||||||
|
drop table if exists per_table_ttl_02265;
|
||||||
|
create table per_table_ttl_02265 (key Int, date Date, value String) engine=MergeTree() order by key;
|
||||||
|
insert into per_table_ttl_02265 values (1, today(), '1');
|
||||||
|
|
||||||
|
-- { echoOn }
|
||||||
|
alter table per_table_ttl_02265 modify TTL date + interval 1 month;
|
||||||
|
select count() from system.mutations where database = currentDatabase() and table = 'per_table_ttl_02265';
|
||||||
|
alter table per_table_ttl_02265 modify TTL date + interval 1 month;
|
||||||
|
select count() from system.mutations where database = currentDatabase() and table = 'per_table_ttl_02265';
|
||||||
|
alter table per_table_ttl_02265 modify TTL date + interval 2 month;
|
||||||
|
select count() from system.mutations where database = currentDatabase() and table = 'per_table_ttl_02265';
|
||||||
|
alter table per_table_ttl_02265 modify TTL date + interval 2 month group by key set value = argMax(value, date);
|
||||||
|
select count() from system.mutations where database = currentDatabase() and table = 'per_table_ttl_02265';
|
||||||
|
alter table per_table_ttl_02265 modify TTL date + interval 2 month group by key set value = argMax(value, date);
|
||||||
|
select count() from system.mutations where database = currentDatabase() and table = 'per_table_ttl_02265';
|
||||||
|
alter table per_table_ttl_02265 modify TTL date + interval 2 month recompress codec(ZSTD(17));
|
||||||
|
select count() from system.mutations where database = currentDatabase() and table = 'per_table_ttl_02265';
|
||||||
|
alter table per_table_ttl_02265 modify TTL date + interval 2 month recompress codec(ZSTD(17));
|
||||||
|
select count() from system.mutations where database = currentDatabase() and table = 'per_table_ttl_02265';
|
||||||
|
|
||||||
|
-- { echoOff }
|
||||||
|
drop table per_table_ttl_02265;
|
Loading…
Reference in New Issue
Block a user