Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 970979FB32A for ; Fri, 27 Jul 2007 18:32:15 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 31439-10 for ; Fri, 27 Jul 2007 18:32:12 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from wx-out-0506.google.com (wx-out-0506.google.com [66.249.82.237]) by postgresql.org (Postfix) with ESMTP id 53A2D9FB2BB for ; Fri, 27 Jul 2007 18:32:12 -0300 (ADT) Received: by wx-out-0506.google.com with SMTP id h29so860989wxd for ; Fri, 27 Jul 2007 14:32:11 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type; b=KmXwXlnd10CMhfveLl9TT+sgr6fXfMeKjFOlMh/1jDCeuytgVwBdUWUEvvwUFISD7eCfbDMU58Kzm6PnRvEzZxur2h92/3OXADGGaXx/czH8i4Zpzm0JZGaY6bc3R5sSuMjWJYPZ8lO0y2gaZxRy0qVJzMPwNNsnUBOhy5w9w7Y= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:mime-version:content-type; b=lmxvDjeATqvFYpsolLJFcFrLplCS0dorXJci9y38EFdstRU5mit3jZW68umrtWKSm3pTK0pMKfzf13GdBRqr56gt1pCkRzuQPE0iA5mepTDrhHtFaaVZ0T12UQ87yiLkRCmZ6Hkm2VdZRb/Wl/vRVoiR9KIZ4lu4MrMU4mwZKIY= Received: by 10.70.31.18 with SMTP id e18mr5641540wxe.1185571931257; Fri, 27 Jul 2007 14:32:11 -0700 (PDT) Received: by 10.70.131.9 with HTTP; Fri, 27 Jul 2007 14:32:11 -0700 (PDT) Message-ID: <357fa7590707271432l709da359n68deea693d2c5fdf@mail.gmail.com> Date: Fri, 27 Jul 2007 17:32:11 -0400 From: "Steven Flatt" To: pgsql-performance@postgresql.org Subject: Vacuum looping? MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_11421_18731775.1185571931220" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200707/392 X-Sequence-Number: 26076 ------=_Part_11421_18731775.1185571931220 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Postgres 8.2.4. We have a large table, let's call it "foo", whereby an automated process periodically inserts many (hundreds of thousands or millions) rows into it at a time. It's essentially INSERT INTO foo SELECT FROM WHERE . Recently, for whatever reason, the query started to run out of memory. This happened on the order of 50 times before it was noticed and the process was stopped. (Admittedly, more investigation needs to go into the OOM problem... ) Now autovacuum promptly kicked in trying to clean up this mess, however it couldn't keep up at the rate that dead tuples were being generated. I'm not sure if it got into a weird state. After a few days, long after the inserting process was stopped, we decided to abort the vacuum (which we weren't convinced was doing anything), then start a manual vacuum with a higher vacuum_cost_limit to get things cleaned up quicker. After 28 hours, here was the output of vacuum verbose: # VACUUM VERBOSE foo; INFO: vacuuming "public.foo" INFO: scanned index "foo_pkey" to remove 44739062 row versions DETAIL: CPU 5.74s/26.09u sec elapsed 529.57 sec. INFO: scanned index "foo_1" to remove 44739062 row versions DETAIL: CPU 760.09s/619.83u sec elapsed 56929.54 sec. INFO: scanned index "foo_2" to remove 44739062 row versions DETAIL: CPU 49.35s/99.57u sec elapsed 4410.74 sec. INFO: "foo": removed 44739062 row versions in 508399 pages DETAIL: CPU 47.35s/12.88u sec elapsed 3985.92 sec. INFO: scanned index "foo_pkey" to remove 32534234 row versions DETAIL: CPU 22.05s/32.51u sec elapsed 2259.05 sec. The vacuum then just sat there. What I can't understand is why it went back for a second pass of the pkey index? There was nothing writing to the table once the vacuum began. Is this behaviour expected? Are these times reasonable for a vacuum (on a busy system, mind you)? We have since aborted the vacuum and truncated the table. We're now working on the root OOM problem, which is easier said than done... Steve ------=_Part_11421_18731775.1185571931220 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline
Postgres 8.2.4.
 
We have a large table, let's call it "foo", whereby an automated process periodically inserts many (hundreds of thousands or millions) rows into it at a time.  It's essentially INSERT INTO foo SELECT FROM <another table> WHERE <some conditions>.  Recently, for whatever reason, the query started to run out of memory.  This happened on the order of 50 times before it was noticed and the process was stopped.  (Admittedly, more investigation needs to go into the OOM problem... )
 
Now autovacuum promptly kicked in trying to clean up this mess, however it couldn't keep up at the rate that dead tuples were being generated.  I'm not sure if it got into a weird state.  After a few days, long after the inserting process was stopped, we decided to abort the vacuum (which we weren't convinced was doing anything), then start a manual vacuum with a higher vacuum_cost_limit to get things cleaned up quicker.
 
After 28 hours, here was the output of vacuum verbose:
 
# VACUUM VERBOSE foo;
INFO:  vacuuming "public.foo"
INFO:  scanned index "foo_pkey" to remove 44739062 row versions
DETAIL:  CPU 5.74s/26.09u sec elapsed 529.57 sec.
INFO:  scanned index "foo_1" to remove 44739062 row versions
DETAIL:  CPU 760.09s/619.83u sec elapsed 56929.54 sec.
INFO:  scanned index "foo_2" to remove 44739062 row versions
DETAIL:  CPU 49.35s/99.57u sec elapsed 4410.74 sec.
INFO:  "foo": removed 44739062 row versions in 508399 pages
DETAIL:  CPU 47.35s/12.88u sec elapsed 3985.92 sec.
INFO:  scanned index "foo_pkey" to remove 32534234 row versions
DETAIL:  CPU 22.05s/32.51u sec elapsed 2259.05 sec.
 
The vacuum then just sat there.  What I can't understand is why it went back for a second pass of the pkey index?  There was nothing writing to the table once the vacuum began.  Is this behaviour expected?  Are these times reasonable for a vacuum (on a busy system, mind you)?
 
We have since aborted the vacuum and truncated the table.  We're now working on the root OOM problem, which is easier said than done...
 
Steve
 
------=_Part_11421_18731775.1185571931220--