2021-08-10 15:55:02 +00:00
|
|
|
|
|
|
|
-- Use DateTime('UTC') to have a common rollup window
|
2020-04-14 17:09:11 +00:00
|
|
|
drop table if exists test_graphite;
|
2021-08-10 15:55:02 +00:00
|
|
|
create table test_graphite (key UInt32, Path String, Time DateTime('UTC'), Value Float64, Version UInt32, col UInt64)
|
2021-07-26 04:03:38 +00:00
|
|
|
engine = GraphiteMergeTree('graphite_rollup') order by key settings index_granularity=10;
|
2020-04-14 17:09:11 +00:00
|
|
|
|
2021-08-12 10:53:32 +00:00
|
|
|
SET joined_subquery_requires_alias = 0;
|
2020-04-14 17:09:11 +00:00
|
|
|
|
2021-08-12 10:53:32 +00:00
|
|
|
INSERT into test_graphite
|
|
|
|
WITH dates AS
|
|
|
|
(
|
2021-08-12 15:08:39 +00:00
|
|
|
SELECT toStartOfDay(toDateTime(now('UTC'), 'UTC')) as today,
|
|
|
|
today - INTERVAL 3 day as older_date
|
2021-08-12 10:53:32 +00:00
|
|
|
)
|
|
|
|
-- Newer than 2 days are kept in windows of 600 seconds
|
2021-08-15 06:06:42 +00:00
|
|
|
select 1 AS key, 'sum_1' AS s, today - number * 60 - 30, number, 1, number from dates, numbers(300) union all
|
2021-08-12 15:08:39 +00:00
|
|
|
select 2, 'sum_1', today - number * 60 - 30, number, 1, number from dates, numbers(300) union all
|
|
|
|
select 1, 'sum_2', today - number * 60 - 30, number, 1, number from dates, numbers(300) union all
|
|
|
|
select 2, 'sum_2', today - number * 60 - 30, number, 1, number from dates, numbers(300) union all
|
|
|
|
select 1, 'max_1', today - number * 60 - 30, number, 1, number from dates, numbers(300) union all
|
|
|
|
select 2, 'max_1', today - number * 60 - 30, number, 1, number from dates, numbers(300) union all
|
|
|
|
select 1, 'max_2', today - number * 60 - 30, number, 1, number from dates, numbers(300) union all
|
|
|
|
select 2, 'max_2', today - number * 60 - 30, number, 1, number from dates, numbers(300) union all
|
2020-04-14 17:09:11 +00:00
|
|
|
|
2021-08-12 10:53:32 +00:00
|
|
|
-- Older than 2 days use 6000 second windows
|
2021-08-15 08:28:08 +00:00
|
|
|
select 1 AS key, 'sum_1' AS s, older_date - number * 60 - 30, number, 1, number from dates, numbers(1200) union all
|
2021-08-12 15:08:39 +00:00
|
|
|
select 2, 'sum_1', older_date - number * 60 - 30, number, 1, number from dates, numbers(1200) union all
|
|
|
|
select 1, 'sum_2', older_date - number * 60 - 30, number, 1, number from dates, numbers(1200) union all
|
|
|
|
select 2, 'sum_2', older_date - number * 60 - 30, number, 1, number from dates, numbers(1200) union all
|
|
|
|
select 1, 'max_1', older_date - number * 60 - 30, number, 1, number from dates, numbers(1200) union all
|
|
|
|
select 2, 'max_1', older_date - number * 60 - 30, number, 1, number from dates, numbers(1200) union all
|
|
|
|
select 1, 'max_2', older_date - number * 60 - 30, number, 1, number from dates, numbers(1200) union all
|
|
|
|
select 2, 'max_2', older_date - number * 60 - 30, number, 1, number from dates, numbers(1200);
|
2020-04-14 17:09:11 +00:00
|
|
|
|
2021-10-19 13:26:16 +00:00
|
|
|
select key, Path, Value, Version, col from test_graphite final order by key, Path, Time desc;
|
2020-11-11 15:29:36 +00:00
|
|
|
|
2021-10-20 13:43:39 +00:00
|
|
|
optimize table test_graphite final;
|
|
|
|
|
|
|
|
select key, Path, Value, Version, col from test_graphite order by key, Path, Time desc;
|
|
|
|
|
2020-11-11 15:29:36 +00:00
|
|
|
drop table test_graphite;
|