Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id AACC31F6FE31 for ; Wed, 11 Jul 2012 18:05:12 -0300 (ADT) Received: from relay3-d.mail.gandi.net ([217.70.183.195]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Sp45t-0005Zi-Jj for pgsql-performance@postgresql.org; Wed, 11 Jul 2012 21:05:11 +0000 X-Originating-IP: 217.70.178.136 Received: from mfilter7-d.gandi.net (mfilter7-d.gandi.net [217.70.178.136]) by relay3-d.mail.gandi.net (Postfix) with ESMTP id D8FE5A807D; Wed, 11 Jul 2012 23:04:45 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mfilter7-d.gandi.net Received: from relay3-d.mail.gandi.net ([217.70.183.195]) by mfilter7-d.gandi.net (mfilter7-d.gandi.net [10.0.15.180]) (amavisd-new, port 10024) with ESMTP id FZ4CeWqwKktM; Wed, 11 Jul 2012 23:04:44 +0200 (CEST) X-Originating-IP: 98.27.54.176 Received: from [192.168.10.146] (cpe-098-027-054-176.nc.res.rr.com [98.27.54.176]) (Authenticated sender: adsend@dunslane.net) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 04AF3A80A7; Wed, 11 Jul 2012 23:04:41 +0200 (CEST) Message-ID: <4FFDEA67.6000801@dunslane.net> Date: Wed, 11 Jul 2012 17:04:39 -0400 From: Andrew Dunstan User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120605 Thunderbird/13.0 MIME-Version: 1.0 To: sthomas@optionshouse.com CC: Craig James , Tom Lane , Daniel Farina , Craig Ringer , "pgsql-performance@postgresql.org" Subject: Re: DELETE vs TRUNCATE explanation References: <4FFCCAC4.4030503@ringerc.id.au> <23853.1342015548@sss.pgh.pa.us> <4FFDE659.7040104@optionshouse.com> In-Reply-To: <4FFDE659.7040104@optionshouse.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.6 (--) X-Archive-Number: 201207/139 X-Sequence-Number: 47320 On 07/11/2012 04:47 PM, Shaun Thomas wrote: > On 07/11/2012 03:18 PM, Craig James wrote: > >> It strikes me as a contrived case rather than a use case. What sort of >> app repeatedly fills and truncates a small table thousands of times ... >> other than a test app to see whether you can do it or not? > > Test systems. Any company with even a medium-size QA environment will > have continuous integration systems that run unit tests on a trash > database hundreds or thousands of times through the day. Aside from > dropping/creating the database via template, which would be *really* > slow, truncate is the easiest/fastest way to reset between tests. Why is recreating the test db from a (populated) template going to be slower than truncating all the tables and repopulating from an external source? I had a client who achieved a major improvement in speed and reduction in load by moving to this method of test db setup. cheers andrew