Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 3D7EF2B0133 for ; Tue, 10 Jul 2012 21:37:44 -0300 (ADT) Received: from mail-pb0-f46.google.com ([209.85.160.46]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Sokw3-0001Fn-3C for pgsql-performance@postgresql.org; Wed, 11 Jul 2012 00:37:44 +0000 Received: by pbbrp8 with SMTP id rp8so1082190pbb.19 for ; Tue, 10 Jul 2012 17:37:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding:x-gm-message-state; bh=ZuW3wyAhoMqd7WbrcU5gdNT0MVoPZtTClNVEBUZfu1g=; b=XOc1KeNG6wKegOJLjLT46LZvoRRSlSjPzem0j45ILXA6DLcPng2mSxfqoDnke5Lr9h egp6VW7YAllpS2emTLid9nYpf66D4r+nSbSYpBSScABEtpFwNQt/G9z2VfrULgjLIM2M WLB0wqM42dl2CtdXMrruCoCXcK3Yf2GXBRhGZVvqlnSE1K1tlfqsux7Myg+40aNYT2/4 qDKSpxzIGaU8Ahjxw60HY4cRNx8Osn3QuH8YstSLHLJ3p7oAaOyB/33V2TIyrlnDEB2D Y5jMlpPoCsyS5Mp1LdU7WJePpJ1mO/INrosHa6wjJV9mXAETXRxbjl7qFOij0cJ8o00G iCJA== Received: by 10.68.227.163 with SMTP id sb3mr74452393pbc.74.1341967049368; Tue, 10 Jul 2012 17:37:29 -0700 (PDT) Received: from ayaki.localdomain (124-169-84-247.dyn.iinet.net.au. [124.169.84.247]) by mx.google.com with ESMTPS id ng8sm535813pbc.13.2012.07.10.17.37.26 (version=SSLv3 cipher=OTHER); Tue, 10 Jul 2012 17:37:28 -0700 (PDT) Message-ID: <4FFCCAC4.4030503@ringerc.id.au> Date: Wed, 11 Jul 2012 08:37:24 +0800 From: Craig Ringer User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120605 Thunderbird/13.0 MIME-Version: 1.0 To: "pgsql-performance@postgresql.org" Subject: DELETE vs TRUNCATE explanation Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gm-Message-State: ALoCoQlOWndMpV3zM5pkt2R867un0OrEmX+BhCgiW/AK2OXbv1E7AKdkeypz466BGl0RyQAJ9iH0 X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201207/124 X-Sequence-Number: 47305 Hi After seeing a few discussions here and on Stack Overflow I've put together a quick explanation of why "DELETE FROM table;" may be faster than "TRUNCATE table" for people doing unit testing on lots of tiny tables, people who're doing this so often they care how long it takes. I'd love it if a few folks who know the guts were to take a look and verify its correctness: http://stackoverflow.com/a/11423886/398670 -- Craig Ringer