I have a table named transactions (alias txs for short) that contains 15 million rows PARTITIONED BY txs.year for data accumulated over last 10-years (approx. 1 to 1.5-million rows/year). Source of this data is a MySQL database and the only data that changes is the data for current year. My strategy is to setup a daily CRON job that exports all records for current year in a compressed CSV format (i.e. 20XX-txs.csv.gz) and then use AWS Glue/PySpark to convert it to snappy.parquet format PARTITIONED BY txs.year.
I've read that you can easily DROP PARTITIONS with ClickHouse (reference). One thing throws me off without any further explanation. Their documentation states:
Deletes the specified partition from the table. This query tags the partition as inactive and deletes data completely, approximately in 10 minutes.
What I am wondering is :
- Where does the 10 minutes part come in? From my tests, I see the partition gone immediately.
- Can I
INSERTupdated data from the newly createdsnappy.parquetpartition immediately afterDROPPINGthe stale partition forcurrent_yearor do I have to wait the full 10 minutes prior to doing so?
Example use case:
# STEP 1: Get updated data for current_year
# -----------------------------------------
$ wget https://s3.amazonaws.com/xxx.xxx/2021-txs.snappy.parquet
# STEP 2: Drop existing PARTITION for current_year
# -----------------------------------------
$ clickhouse-client --query="ALTER TABLE txs DROP PARTITION '2021'"
# STEP 3: INSERT updated data for current_year into the table
# -----------------------------------------
$ cat 2021-txs.snappy.parquet | clickhouse-client --query="INSERT INTO txs FORMAT Parquet"