
86.3K
COThis is a very common but tricky SQL interview question.
Why is deleting many rows slower than TRUNCATE in SQL?
1️⃣ DELETE removes rows one by one
Each row deletion is logged individually.
Indexes are updated for every row.
2️⃣ TRUNCATE removes data at once
It deallocates entire data pages.
No row-by-row processing.
3️⃣ Logging difference
DELETE generates heavy transaction logs.
TRUNCATE logs minimal metadata changes.
4️⃣ Trigger & constraint behavior
DELETE fires triggers and checks constraints.
TRUNCATE usually does not.
5️⃣ Rollback impact
DELETE can be rolled back normally.
TRUNCATE behavior depends on DB engine.
⸻
🎯 Interview takeaway
DELETE = row-by-row operation.
TRUNCATE = bulk structural operation.
More logging + more index updates = slower DELETE.
{ SQL, Databases, QueryOptimization, BackendEngineering, InterviewPrep, Performance }
#SQL
#Databases
#BackendEngineering
#SystemDesign
#TechExplained
@codemeetstech










