Use TTLs, partition-level deletes, and role-based security to fulfill GDPR obligations in ClickHouse.
Delete personal data on request, retain only necessary data, and protect data from unauthorized access. ClickHouse offers TTL clauses, ALTER TABLE … DELETE
, and granular privileges to achieve this.
Issue an ALTER TABLE … DELETE WHERE
to wipe all rows containing that customer’s ID or email. Run a OPTIMIZE TABLE … FINAL
afterwards to purge data files.
ALTER TABLE Orders DELETE WHERE customer_id = 42;
OPTIMIZE TABLE Orders FINAL;
Add a TTL clause during table creation or via ALTER TABLE … MODIFY TTL
. TTL moves expired rows to another table or deletes them, ensuring retention limits.
ALTER TABLE Customers
MODIFY TTL created_at + INTERVAL 3 YEAR DELETE;
Create roles with least-privilege grants and attach them to users. Mask sensitive columns with views or omit them entirely in restricted roles.
CREATE ROLE analyst;
GRANT SELECT(name, created_at) ON Customers TO analyst;
GRANT analyst TO bob;
Encrypt PII such as emails before insert. ClickHouse has no built-in transparent encryption, so encrypt in the application layer and store ciphertext.
Write each GDPR deletion into a dedicated gdpr_events
table. This audit trail proves compliance during regulatory reviews.
No native feature exists. Encrypt sensitive values in the application before inserting.
Execution is instantaneous, but physical removal occurs during the next merge or after an explicit OPTIMIZE FINAL.
Not after OPTIMIZE. Keep encrypted backups if reversibility is required.