Received: from localhost (unknown [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id C05679FC0C8 for ; Tue, 23 Oct 2007 13:56:07 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 38591-01 for ; Tue, 23 Oct 2007 13:55:59 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from pd2mo3so.prod.shaw.ca (idcmail-mo1so.shaw.ca [24.71.223.10]) by postgresql.org (Postfix) with ESMTP id 8E7189FC0FE for ; Tue, 23 Oct 2007 13:56:00 -0300 (ADT) Received: from pd3mr2so.prod.shaw.ca (pd3mr2so-qfe3.prod.shaw.ca [10.0.141.178]) by l-daemon (Sun ONE Messaging Server 6.0 HotFix 1.01 (built Mar 15 2004)) with ESMTP id <0JQD008ILJ00HSA0@l-daemon> for pgsql-performance@postgresql.org; Tue, 23 Oct 2007 10:55:12 -0600 (MDT) Received: from pn2ml7so.prod.shaw.ca ([10.0.121.151]) by pd3mr2so.prod.shaw.ca (Sun Java System Messaging Server 6.2-7.05 (built Sep 5 2006)) with ESMTP id <0JQD00BFSIZZOYA0@pd3mr2so.prod.shaw.ca> for pgsql-performance@postgresql.org; Tue, 23 Oct 2007 10:55:12 -0600 (MDT) Received: from [192.168.0.102] ([24.68.192.206]) by l-daemon (Sun ONE Messaging Server 6.0 HotFix 1.01 (built Mar 15 2004)) with ESMTP id <0JQD00G25IZYNZQ1@l-daemon> for pgsql-performance@postgresql.org; Tue, 23 Oct 2007 10:55:10 -0600 (MDT) Date: Tue, 23 Oct 2007 09:52:52 -0700 From: Ron St-Pierre Subject: Re: 12 hour table vacuums In-reply-to: <87y7dtokfu.fsf@oxford.xeocode.com> To: Gregory Stark Cc: pgsql-performance@postgresql.org Message-id: <471E26E4.7040804@shaw.ca> MIME-version: 1.0 Content-type: text/plain; charset=ISO-8859-1; format=flowed Content-transfer-encoding: 7bit References: <471E18ED.3090704@shaw.ca> <87y7dtokfu.fsf@oxford.xeocode.com> User-Agent: Thunderbird 2.0.0.6 (Windows/20070728) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200710/260 X-Sequence-Number: 27282 Gregory Stark wrote: > "Ron St-Pierre" writes: > > >> We vacuum only a few of our tables nightly, this one is the last one because it >> takes longer to run. I'll probably re-index it soon, but I would appreciate any >> advice on how to speed up the vacuum process (and the db in general). >> > ... > >> vacuum_cost_delay = 200 >> > > Well speeding up vacuum isn't really useful in itself. In fact you have vacuum > configured to run quite slowly by having vacuum_cost_delay set so high. You > have it set to sleep 200ms every few pages. If you lower that it'll run faster > but take more bandwidth away from the foreground tasks. > It's okay if it uses a lot of resources, because it's scheduled to run during the night (our slow time). Because most of the important queries running during the day use this table, I want the vacuum analzye finished ASAP. > >> Here's the table information: >> The table has 140,000 rows, 130 columns (mostly NUMERIC), 60 indexes. >> > > For what it's worth NUMERIC columns take more space than you might expect. > Figure a minimum of 12 bytes your rows are at about 1.5k each even if the > non-numeric columns aren't large themselves. What are the other columns? > The NUMERIC columns hold currency related values, with values ranging from a few cents to the billions, as well as a few negative numbers. > >> We were running autovacuum but it interfered with the updates to we shut it >> off. >> > > Was it just the I/O bandwidth? I'm surprised as your vacuum_cost_delay is > quite high. Manual vacuum doesn't do anything differently from autovacuum, > neither should interfere directly with updates except by taking away > I/O bandwidth. > > I don't know what the problem was. I tried to exclude certain tables from autovacuuming, but it autovacuumed anyway. >> We vacuum this table nightly, and it currently takes about 12 hours to >> vacuum it. Not much else is running during this period, nothing that should >> affect the table. >> > > Is this time increasing over time? If once a day isn't enough then you may be > accumulating more and more dead space over time. In which case you may be > better off running it during prime time with a large vacuum_cost_delay (like > the 200 you have configured) rather than trying to get to run fast enough to > fit in the off-peak period. > > >> deadlock_timeout = 10000 >> > > I would not suggest having this quite this high. Raising it from the default > is fine but having a value larger than your patience is likely to give you the > false impression that something is hung if you should ever get a deadlock. > > Good point. I'll look into this. Thanks Ron