<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Delete on Postgres Scripts</title><link>https://www.postgresscripts.com/tags/delete/</link><description>Recent content in Delete on Postgres Scripts</description><generator>Hugo -- gohugo.io</generator><language>en</language><copyright>PostgresScripts.com</copyright><lastBuildDate>Tue, 16 Jun 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://www.postgresscripts.com/tags/delete/index.xml" rel="self" type="application/rss+xml"/><item><title>TRUNCATE vs DELETE vs DROP: Remove Rows Fast in PostgreSQL</title><link>https://www.postgresscripts.com/post/remove-all-rows-fast-truncate-vs-delete-vs-drop-in-postgresql/</link><pubDate>Tue, 16 Jun 2026 00:00:00 +0000</pubDate><guid>https://www.postgresscripts.com/post/remove-all-rows-fast-truncate-vs-delete-vs-drop-in-postgresql/</guid><description>
&lt;h2 id="truncate-vs-delete-vs-drop-remove-rows-fast-in-postgresql"&gt;TRUNCATE vs DELETE vs DROP: Remove Rows Fast in PostgreSQL&lt;/h2&gt;
&lt;p&gt;Where &lt;code&gt;DELETE&lt;/code&gt; removes rows one logical version at a time and leaves the cleanup to vacuum, &lt;code&gt;TRUNCATE&lt;/code&gt; discards an entire table's contents almost instantly and reclaims the space immediately, and &lt;code&gt;DROP&lt;/code&gt; removes the table itself. Picking the wrong one for &amp;quot;empty this table&amp;quot; is a common cause of surprise WAL floods and runaway bloat.&lt;/p&gt;
&lt;script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1012089347386563"
crossorigin="anonymous"&gt;&lt;/script&gt;
&lt;ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-1012089347386563"
data-ad-slot="7945792173"
data-ad-format="auto"
data-full-width-responsive="true"&gt;&lt;/ins&gt;
&lt;script&gt;
(adsbygoogle = window.adsbygoogle || []).push({});
&lt;/script&gt;
&lt;h2 id="purpose-and-overview"&gt;Purpose and Overview&lt;/h2&gt;
&lt;p&gt;&amp;quot;Just clear the table&amp;quot; sounds like one operation, but PostgreSQL offers three commands with very different costs. The reason the choice matters comes down to how PostgreSQL stores data. Under multiversion concurrency control (MVCC), a &lt;code&gt;DELETE&lt;/code&gt; does not physically remove a row — it marks each row version as deleted by stamping its &lt;code&gt;xmax&lt;/code&gt;, leaving a dead tuple behind. Those dead tuples occupy space until vacuum reclaims them, and on a full-table delete that means writing one WAL record per row and generating dead tuples across the entire table.&lt;/p&gt;</description></item></channel></rss>