Václav Málek
12/21/2022, 6:35 AMAndrey Pechkurov
12/21/2022, 7:32 AMselect min(ts) min_ts from x
Next, drop the partition:
alter table x drop partition where ts = :min_ts
when storage reaches 90% of used spaceYou should write a cron job that would be checking the disk space and running the above statements when the disk is almost full.
javier ramirez
12/21/2022, 9:01 AMSELECT ts FROM x LIMIT 1
? I would say in the absence of aggregations or order by
, the LIMIT 1
should return the earliest designated timestamp, and in that case the query should be faster than using min()
Andrey Pechkurov
12/21/2022, 9:18 AMselect ts from x limit 1
would work just fine and indeed it would be fasterjavier ramirez
12/21/2022, 9:24 AMalter table
query you will need the timestamp to be at the same resolution level than your partitioning. For example, I have a table where I have daily partitioning but microsecond resolution in my timestamps, so my earlier timestamp is 2022-10-28T19:15:48.741819Z.
If I try to drop a partition WHERE ts = '2022-10-28T19:15:48.741819Z'
I am getting an error saying no partitions matched WHERE clause
.
I can do something like this instead
alter table 'ilp_test' drop partition where _timestamp_ = *timestamp_floor('d', to_timestamp('2022-10-28T19:15:48.741819Z', 'yyyy-MM-ddTHH:mm:ss.SSSUUUZ'))*;
Now the timestamp is at day resolution, and the partition is dropped successfullyAndrey Pechkurov
12/21/2022, 9:25 AMjavier ramirez
12/21/2022, 9:28 AMtimestamp_floor,
so it can be simplified as
alter table 'ilp_test' drop partition where _timestamp_ = *timestamp_floor('d', '2022-10-28T19:15:48.741819Z')*;
Andrey Pechkurov
12/21/2022, 9:30 AM