I have several time-series tables with daily partitioning on a QuestDB database. I would like to remove every day all the partitions older than 21 days from my tables. What would be the best way to do it?
Thanks
I have several time-series tables with daily partitioning on a QuestDB database. I would like to remove every day all the partitions older than 21 days from my tables. What would be the best way to do it?
Thanks
You can use
ALTER TABLE...DROP PARTITION
to remove old partitions from a particular table. You can execute this command either via pgwire API or via REST API. When working with a cronjob probably API is the most convenient way and you could execute something likeTo make it more interesting, you could go over all the tables on your database with daily partitioning, and calculate automatically what is the date range to delete. I am pasting a simple bash script to do so. The script depends on
curl
andjq
and has been tested on both Ubuntu and OSx.