Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UeGGC-0000Cv-2P for pgsql-performance@arkaria.postgresql.org; Mon, 20 May 2013 02:55:40 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UeGGB-0001ow-8G for pgsql-performance@arkaria.postgresql.org; Mon, 20 May 2013 02:55:39 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UeGGA-0001oq-5F for pgsql-performance@postgresql.org; Mon, 20 May 2013 02:55:38 +0000 Received: from moutng.kundenserver.de ([212.227.126.187]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UeGG3-0001QG-Vs for pgsql-performance@postgresql.org; Mon, 20 May 2013 02:55:37 +0000 Received: from [192.168.1.110] (mail.highperformancepostgresql.com [71.179.240.8]) by mrelayeu.kundenserver.de (node=mrbap0) with ESMTP (Nemesis) id 0MI8cw-1Udj5z2S6w-003sMH; Mon, 20 May 2013 04:55:30 +0200 Message-ID: <519990A0.6030402@2ndQuadrant.com> Date: Sun, 19 May 2013 22:55:28 -0400 From: Greg Smith User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:14.0) Gecko/20120713 Thunderbird/14.0 MIME-Version: 1.0 To: Rob Emery CC: pgsql-performance@postgresql.org Subject: Re: Deleting Rows From Large Tables References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:Ou48OGqHH2WsO70ZEc1FignuokeR9ow1sCWqirEvRQY /45RRq3cebJMyIJycoK3gFYCZYdNi9qoe6/9lEhPAWmeT4E2yU yomSOoe32ECYEHzhkRjpFjjQB3CTEnloZN1B1NrbqgYrZuxUWZ 2IhPCVoVCd4UsnkP2bZLdFFqK7b3ktHc4JLZUqt4UEcjPLPH0q 0nEVqbqqvza9MEmDF7FNL42OrJTMWBhWasGLc2SNrEDY/givLE TQUvP7/dh7E6N35XRo1EwB542eNY+qm0YjVvEu+q78ZKgLssAM e6QmytJHm8bGPKFirbpIfFM0KseIpwywIxmbn91Yju+GkyIomG 4lgZ8B4L63297uRVIyAI= X-Pg-Spam-Score: 0.8 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org On 5/17/13 7:26 AM, Rob Emery wrote: > I can keep decreasing the size of > the window I'm deleting but I feel I must be doing something either > fundamentally wrong or over-complicating this enormously. I've had jobs like this where we ended up making the batch size cover only 4 hours at a time. Once you've looked at the EXPLAIN plans for the row selection criteria and they're reasonable, dropping the period that's deleted per pass is really the only thing you can do. Do some DELETEs, then pause to let the disk cache clear; repeat. The other useful thing to do here is get very aggressive about settings for shared_buffers, checkpoint_segments, and checkpoint_timeout. I'll normally push for settings like 8GB/256/15 minutes when doing this sort of thing. The usual situation with a checkpoint every 5 minutes may not be feasible when you've got this type of work going on in the background. -- Greg Smith 2ndQuadrant US greg@2ndQuadrant.com Baltimore, MD PostgreSQL Training, Services, and 24x7 Support www.2ndQuadrant.com -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance