Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 9FCCD9FB1EB for ; Sat, 25 Nov 2006 11:45:33 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-new, port 10024) with ESMTP id 32639-10 for ; Sat, 25 Nov 2006 11:45:21 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from nf-out-0910.google.com (nf-out-0910.google.com [64.233.182.191]) by postgresql.org (Postfix) with ESMTP id D3E979FB1CC for ; Sat, 25 Nov 2006 11:45:21 -0400 (AST) Received: by nf-out-0910.google.com with SMTP id x4so1655222nfb for ; Sat, 25 Nov 2006 07:45:20 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=LEBUrZ3n0rN+8A55WWlYvwyp7iLRZSPVQdiVwXvFHhXE4tTXb2NFFhM6QDP/BaCFUje29auINyVZkN4sFpom07p/HSUpQWZPETMGTSygjSOi/JXsWiWczoazpQa/iG3ooJWcr8qJ8ovHwbry4jwmjKdJE+6Cz9DIMav4rJVrIyE= Received: by 10.78.81.20 with SMTP id e20mr11534794hub.1164469519628; Sat, 25 Nov 2006 07:45:19 -0800 (PST) Received: by 10.78.107.14 with HTTP; Sat, 25 Nov 2006 07:45:19 -0800 (PST) Message-ID: Date: Sat, 25 Nov 2006 15:45:19 +0000 From: "Peter Childs" To: pgsql-performance@postgresql.org Subject: Massive delete of rows, how to proceed? In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <45673D56.10707@andromeiberica.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200611/215 X-Sequence-Number: 21985 On 24/11/06, Arnau wrote: > Hi all, > > I have a table with statistics with more than 15 million rows. I'd > like to delete the oldest statistics and this can be about 7 million > rows. Which method would you recommend me to do this? I'd be also > interested in calculate some kind of statistics about these deleted > rows, like how many rows have been deleted for date. I was thinking in > creating a function, any recommendations? Copy and drop old table. If you delete you will have a massive problem with a bloated table and vacuum will not help unless you expect the table to grow to this size regulally otherwise vacuum full will take ages. Peter.