惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
The Blog of Author Tim Ferriss
TaoSecurity Blog
TaoSecurity Blog
U
Unit 42
Blog — PlanetScale
Blog — PlanetScale
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
大猫的无限游戏
大猫的无限游戏
NISL@THU
NISL@THU
Scott Helme
Scott Helme
G
Google Developers Blog
T
Threat Research - Cisco Blogs
aimingoo的专栏
aimingoo的专栏
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Apple Machine Learning Research
Apple Machine Learning Research
H
Hackread – Cybersecurity News, Data Breaches, AI and More
T
The Exploit Database - CXSecurity.com
G
GRAHAM CLULEY
The Cloudflare Blog
The Hacker News
The Hacker News
Spread Privacy
Spread Privacy
N
Netflix TechBlog - Medium
Hacker News: Ask HN
Hacker News: Ask HN
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
C
Cisco Blogs
O
OpenAI News
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Forbes - Security
Forbes - Security
Recorded Future
Recorded Future
C
CXSECURITY Database RSS Feed - CXSecurity.com
D
DataBreaches.Net
云风的 BLOG
云风的 BLOG
S
Security Affairs
B
Blog RSS Feed
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
P
Privacy & Cybersecurity Law Blog
Martin Fowler
Martin Fowler
Know Your Adversary
Know Your Adversary
F
Full Disclosure
The GitHub Blog
The GitHub Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Google DeepMind News
Google DeepMind News
博客园 - Franky
F
Fortinet All Blogs
Last Week in AI
Last Week in AI
C
Cybersecurity and Infrastructure Security Agency CISA
L
Lohrmann on Cybersecurity
T
Tenable Blog
V
V2EX
W
WeLiveSecurity
Google Online Security Blog
Google Online Security Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
Day 37: How to Handle Updates and Deletes in ClickHouse® (Mutations)
Kanishga Subramani · 2026-06-25 · via DEV Community

How to Handle Updates and Deletes in ClickHouse® (Mutations)

Introduction

ClickHouse® is designed for high-speed analytical queries and large-scale data ingestion. Since it is optimized for append-only workloads, updating or deleting existing records works differently than in traditional row-oriented databases.

Instead of modifying rows in place, ClickHouse® uses Mutations—background operations that rewrite entire data parts on disk.

In this blog, you'll learn:

  • What mutations are
  • How updates and deletes work
  • Lightweight deletes
  • Partition-level deletion
  • Monitoring mutation progress
  • Best practices for minimizing performance impact

What Are Mutations?

A mutation is a background operation that modifies or removes existing data by rewriting the affected data parts on disk.

Mutations are triggered using:

  • ALTER TABLE ... UPDATE
  • ALTER TABLE ... DELETE

Key Characteristics

  • Asynchronous – The command returns immediately, while the actual work happens in the background.
  • Part-based – ClickHouse rewrites entire data parts rather than individual rows.
  • Resource intensive – Large mutations consume CPU, disk I/O, and storage bandwidth.
  • Non-transactional – Mutations cannot be rolled back.
  • Trackable – Progress can be monitored using the system.mutations table.

Because of these characteristics, mutations are best suited for:

  • Occasional data corrections
  • Compliance-related deletions
  • Bulk updates

They should not be used for frequent row-level modifications.


Sample Table

We'll use the following orders table throughout this article.

CREATE TABLE default.orders
(
    order_id UInt32,
    customer_id UInt32,
    country LowCardinality(String),
    status LowCardinality(String),
    amount Float64,
    order_date DateTime
)
ENGINE = MergeTree()
PARTITION BY toYYYYMM(order_date)
ORDER BY (country, status, order_date);

Insert sample data:

INSERT INTO default.orders VALUES
(1,101,'IN','completed',1200.00,'2024-01-05 10:00:00'),
(2,102,'US','pending',450.00,'2024-01-06 11:00:00'),
(3,103,'GB','completed',890.00,'2024-01-07 09:30:00'),
(4,104,'IN','cancelled',300.00,'2024-01-08 14:00:00'),
(5,105,'DE','completed',670.00,'2024-01-09 16:00:00');


1. Updating Data

Syntax

ALTER TABLE table_name
UPDATE column1 = value1,
       column2 = value2
WHERE condition;


Example 1: Update a Single Row

Update order 2 from pending to completed.

ALTER TABLE default.orders
UPDATE status = 'completed'
WHERE order_id = 2;

Result:

order_id status
2 completed

Example 2: Update Multiple Columns

ALTER TABLE default.orders
UPDATE
    status = 'completed',
    amount = 500
WHERE order_id = 4;

Result:

order_id status amount
4 completed 500.00

Example 3: Bulk Update

Update all orders from India.

ALTER TABLE default.orders
UPDATE status = 'reviewed'
WHERE country = 'IN';

Result:

order_id country status
1 IN reviewed
4 IN reviewed

2. Deleting Data Using Mutations

Syntax

ALTER TABLE table_name
DELETE WHERE condition;


Example 1: Delete a Single Row

ALTER TABLE default.orders
DELETE WHERE order_id = 4;

Remaining rows:

order_id status
1 completed
2 pending
3 completed
5 completed

Example 2: Delete Older Data

Delete orders before January 7, 2024.

ALTER TABLE default.orders
DELETE
WHERE order_date < '2024-01-07';

Remaining rows:

order_id order_date
3 2024-01-07 09:30:00
4 2024-01-08 14:00:00
5 2024-01-09 16:00:00

3. Lightweight Deletes (DELETE FROM)

Starting with ClickHouse v22.8, lightweight deletes provide a much faster way to remove rows.

Instead of rewriting data parts immediately, ClickHouse marks rows as deleted. Physical removal occurs during future merge operations.

Syntax

DELETE FROM table_name
WHERE condition;

Example

DELETE FROM default.orders
WHERE status = 'cancelled';

Mutation vs Lightweight Delete

Feature ALTER TABLE DELETE DELETE FROM
Speed Slower Faster
Data Rewrite Immediate background mutation During future merges
Availability All versions v22.8+
Best Use Case Large bulk deletes Frequent row deletions

4. DROP PARTITION (Fastest Bulk Delete)

For partitioned tables, deleting an entire partition is significantly faster than deleting rows individually.

ALTER TABLE default.orders
DROP PARTITION '202401';

Advantages:

  • Instant operation
  • No mutation
  • Minimal resource usage
  • Ideal for retention policies

This is the recommended approach for time-series data.


5. TRUNCATE TABLE

To remove all rows from a table:

TRUNCATE TABLE default.orders;

Compared to:

ALTER TABLE default.orders
DELETE WHERE 1=1;

TRUNCATE is much faster because it removes the entire table contents instead of generating a mutation.

Warning: This operation permanently deletes all data.


6. Monitoring Mutations

Since mutations execute asynchronously, ClickHouse provides the system.mutations table to monitor progress.

SELECT
    mutation_id,
    command,
    is_done,
    parts_to_do,
    create_time
FROM system.mutations
WHERE database = 'default'
  AND table = 'orders'
ORDER BY create_time DESC;

Example output:

mutation_id command is_done parts_to_do create_time
0000000001 UPDATE status='completed' 1 0 2024-01-10 10:05:00
0000000002 DELETE WHERE order_id=4 1 0 2024-01-10 10:06:00

Interpretation:

  • is_done = 1 → Mutation completed.
  • parts_to_do > 0 → Mutation is still running.

Cancelling a Mutation

If a mutation is taking too long or impacting cluster performance:

KILL MUTATION
WHERE database = 'default'
  AND table = 'orders'
  AND mutation_id = '0000000001';


Engine Alternatives

If your workload requires frequent updates or deletes, mutations may not be the best solution.

Instead, consider using:

  • ReplacingMergeTree
  • CollapsingMergeTree

These table engines are designed to efficiently handle changing data while maintaining ClickHouse's high-performance architecture.


Best Practices

  • Avoid frequent mutations whenever possible.
  • Use Lightweight Deletes (DELETE FROM) for small, frequent deletions.
  • Use DROP PARTITION for deleting large amounts of time-based data.
  • Always include a WHERE clause to avoid accidental data loss.
  • Monitor long-running mutations using system.mutations.
  • Schedule heavy mutations during off-peak hours.
  • Design your schema to minimize the need for updates and deletes.

Quick Reference

Operation Command
Update rows ALTER TABLE ... UPDATE
Delete rows (mutation) ALTER TABLE ... DELETE
Lightweight delete DELETE FROM ...
Drop partition ALTER TABLE ... DROP PARTITION
Delete all rows TRUNCATE TABLE
Monitor mutations SELECT * FROM system.mutations
Cancel mutation KILL MUTATION

Final Thoughts

Handling updates and deletes in ClickHouse® requires a different mindset than traditional relational databases.

Because ClickHouse is optimized for append-only analytical workloads, updates and deletes are intentionally expensive. Rather than modifying rows directly, ClickHouse rewrites data parts in the background through mutations.

Fortunately, ClickHouse offers multiple strategies depending on your use case:

  • Mutations for occasional updates and deletions
  • Lightweight Deletes for faster row-level removals
  • DROP PARTITION for instant bulk deletion of partitioned data
  • ReplacingMergeTree and CollapsingMergeTree for workloads with frequent data changes

The key to maintaining high performance is choosing the right deletion or update strategy and designing your schema to minimize the need for mutations from the outset.