Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hBmrz-00029y-JZ for pgsql-general@arkaria.postgresql.org; Wed, 03 Apr 2019 20:52:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hBmry-0005NC-F9 for pgsql-general@arkaria.postgresql.org; Wed, 03 Apr 2019 20:52:26 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hBmrx-0005N4-RX for pgsql-general@lists.postgresql.org; Wed, 03 Apr 2019 20:52:26 +0000 Received: from mail-ot1-x342.google.com ([2607:f8b0:4864:20::342]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hBmrr-00038j-43 for pgsql-general@lists.postgresql.org; Wed, 03 Apr 2019 20:52:24 +0000 Received: by mail-ot1-x342.google.com with SMTP id f10so286222otb.6 for ; Wed, 03 Apr 2019 13:52:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language; bh=IbjDi0rNXbYnMUVZ2xo8+47uu5+ZdeaO7JFamyYCiDs=; b=trWxIMrKlPfHKnvfH9KSJGzJ92Mowkw65uJ1XE92ZJCViGemZO2b83AgYSldhbwVum +vGn4r5a1J4j8/DMfNy/zEyBUZF2BgCKcR7ArZLCONdrfTTiFKqqmgzjIAmG3IuWuRZg iH0I+tShA37ywtdYDe3/UEbwwjPDacxkHgzHnRMwtpqzY6bu81l7Gbx7Tgb4mlKaDJbL EovgDdWGUojs6KSVgDbYudQKxonOiO9UP35Wotq6ahKyRM2xhkBJFupJZ2TPgaxC+o1E jlOj/0ZzdOy81Fw52lZJizBd2hK0YfpweM8tde2OPelyVPwmzcu41Xto12HlqCCblYCE EuTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=IbjDi0rNXbYnMUVZ2xo8+47uu5+ZdeaO7JFamyYCiDs=; b=GgD1qtgfr1qEIm21OQfskZ47F4NLi89DGvwmQ6DeKDFZqTwnaU2SoXh+PZzYevcw59 TXq/tMN1DiX8ImOw/IdM5MNjlmRW8ljc2vZjPJv3PtRppBuTQbIosG/uMGhafG2Rmv3G 77esRkKxzuTi4XG6BE7mbtiHh+90AH4H6iPHdWKnLuX5cg2TSZWz4mk9d9ugyie2reRm Eq5GfNwAuOb6QmaqDxcLqRfjoy3LuMlri9ty+Z0AqqyRKX8+plRkr9k3rzpimjn6IUz5 G745HSif1E+kDzWYsliUu4HdWrMrq3CAblX9bY5RhQGxcujqcJ1+HJcoP0MYyHA2xTDh qDQQ== X-Gm-Message-State: APjAAAVMBJoEBwiVclS4BWt5cUzcldRyOkr6Olk+lfeXNwzEElfteb9q MXFCf6WEWoaJtx6IS/G50CVqraHG06w= X-Google-Smtp-Source: APXvYqyL46pOdSACpFBKfE9S1AfMqjru5InjWwws0ARiCbcxqRov9kHckuRlMvGApubpGGGrTrMkpg== X-Received: by 2002:a9d:760b:: with SMTP id k11mr1206967otl.135.1554324737861; Wed, 03 Apr 2019 13:52:17 -0700 (PDT) Received: from [192.168.1.10] (ip70-171-116-89.no.no.cox.net. [70.171.116.89]) by smtp.googlemail.com with ESMTPSA id e67sm8577939ote.13.2019.04.03.13.52.16 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Apr 2019 13:52:17 -0700 (PDT) Subject: Re: Recommendation to run vacuum FULL in parallel To: pgsql-general@lists.postgresql.org References: <9ed59ae2-6eb1-549d-eb05-d1546fd11515@mail.ru> From: Ron Message-ID: Date: Wed, 3 Apr 2019 15:52:16 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------B6FD58DB0664E90071994DED" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------B6FD58DB0664E90071994DED Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 4/3/19 3:45 PM, Perumal Raj wrote: > Hi Stephen > > Thanks for the response , > > Version : 9.2 > We never ran VACUUM FULL in the past, All we are doing just manual vacuum > ( Weekly ) . > Based on the Observation ( test run ) , we were able to reclaim 150 GB out > of 500 GB . > > We are heading to a planned down time soon , So thinking to run FULL > during that time . > > Reason behind to run FULL : 1. Reclaim unused space which postgres never > using it. Did you purge a *lot* of records? >                                                 2. Considering  FULL may > increase the performance. Maybe. But choose your tables wisely. >                                                 3. Daily backup size and > time  will be reduced after reclaiming 150GB. How are you currently performing backups?  (The size won't change if you're using pg_dump, and it won't change much if you're using pgbackrest with the compression option -- thought it will probably run faster.) Bottom line: 1. choose your tables wisely. 2. make sure you have enough disk space. 3. Either autovacuum more aggressively or explicitly vacuum certain tables from a cron job. > > Thanks, > Raj > > > On Wed, Apr 3, 2019 at 1:16 PM Stephen Eilert > wrote: > > > Ideally VACUUM FULL should not require a giant lock on the table. > > It is a massively expensive operation, regardless. Not sure if it is > something you want to run in production outside a maintenance window. > > I would argue that frequent vacuum full is an antipattern. This will > become a matter of superstition in your company. > > If db size growth is a problem, make autovacuum more agressive. Or run > your manual vacuum job (not full) more often than a week. Daily, if > you have to. This will not reclaim disk space as reported by the OS, > but it should make the space available for new row versions, so db > should mostly stop growing from the OS point of view(mostly, because > you may be adding new data, right?). If it is still a problem, then > there may be something else going on. > > Which PG version is that? > > > — Stephen > On Apr 3, 2019, 10:02 AM -0700, Perumal Raj >, wrote: >> Hi All >> >> Thanks for all your valuable  inputs, >> >> Here is some more data, >> >> Though we have 150 GB free space spread across 500 Tables , Every >> alternative day DB is growing with 1 GB rate. >> Also,We have manual vacuum job scheduled to run weekly basis, So >> seems to be space is not reusing all the time ? >> >> So conclude the requirement here , The only way to parallelism is >> multiple script. And no need to do REINDEX exclusively. >> Question : Do we need to consider  Table dependencies while preparing >> script in order to avoid table locks during vacuum full ? >> >> At present Maintenance work memory set to 20 GB. >> Question : Do we need to tweak any other parameters ? >> >> Note: >> We are planning this activity with Application Downtime only. >> >> Let me know if i missed anything. >> >> Regards, >> Raj >> >> >> >> >> >> On Wed, Apr 3, 2019 at 8:42 AM rihad > > wrote: >> >> > And future updates can reuse it, too (an update is very similar >> to an >> > insert+delete). >> >> >> Hm, then it's strange our DB takes 6 times as much space compared to >> freshly restored one (only public schema is considered). >> >> > Not if autovacuum has a chance to run between updates. >> >> Ours is run regularly, although we had to tweak it down not to >> interfere >> with normal database activity, so it takes several hours each run >> on the >> table. We did that by setting autovacuum_vacuum_scale_factor = >> 0.05 from >> default 0.2. >> >> -- Angular momentum makes the world go 'round. --------------B6FD58DB0664E90071994DED Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit On 4/3/19 3:45 PM, Perumal Raj wrote:
Hi Stephen 

Thanks for the response ,

Version : 9.2 
We never ran VACUUM FULL in the past, All we are doing just manual vacuum ( Weekly ) .
Based on the Observation ( test run ) , we were able to reclaim 150 GB out of 500 GB .

We are heading to a planned down time soon , So thinking  to run FULL during that time .

Reason behind to run FULL : 1. Reclaim unused space which postgres never using it.

Did you purge a lot of records?

                                                2. Considering  FULL may increase the performance.

Maybe. But choose your tables wisely.

                                                3. Daily backup size and time  will be reduced after reclaiming 150GB.

How are you currently performing backups?  (The size won't change if you're using pg_dump, and it won't change much if you're using pgbackrest with the compression option -- thought it will probably run faster.)

Bottom line:

1. choose your tables wisely.
2. make sure you have enough disk space.
3. Either autovacuum more aggressively or explicitly vacuum certain tables from a cron job.


Thanks,
Raj


On Wed, Apr 3, 2019 at 1:16 PM Stephen Eilert <contact@stepheneilert.com> wrote:
> Ideally VACUUM FULL should not require a giant lock on the table.

It is a massively expensive operation, regardless. Not sure if it is something you want to run in production outside a maintenance window.

I would argue that frequent vacuum full is an antipattern. This will become a matter of superstition in your company.

If db size growth is a problem, make autovacuum more agressive. Or run your manual vacuum job (not full) more often than a week. Daily, if you have to. This will not reclaim disk space as reported by the OS, but it should make the space available for new row versions, so db should mostly stop growing from the OS point of view(mostly, because you may be adding new data, right?). If it is still a problem, then there may be something else going on.

Which PG version is that?


— Stephen
On Apr 3, 2019, 10:02 AM -0700, Perumal Raj <perucinci@gmail.com>, wrote:
Hi All

Thanks for all your valuable  inputs,

Here is some more data,

Though we have 150 GB free space spread across 500 Tables , Every alternative day DB is growing with 1 GB rate.
Also,We have manual vacuum job scheduled to run weekly basis, So seems to be space is not reusing all the time ?

So conclude the requirement here , The only way to parallelism is multiple script. And no need to do REINDEX exclusively.
Question : Do we need to consider  Table dependencies while preparing script in order to avoid table locks during vacuum full ?

At present Maintenance work memory set to 20 GB.
Question : Do we need to tweak any other parameters ?

Note: 
We are planning this activity with Application Downtime only.

Let me know if i missed anything.

Regards,
Raj
 




On Wed, Apr 3, 2019 at 8:42 AM rihad <rihad@mail.ru> wrote:
> And future updates can reuse it, too (an update is very similar to an
> insert+delete).


Hm, then it's strange our DB takes 6 times as much space compared to
freshly restored one (only public schema is considered).

> Not if autovacuum has a chance to run between updates.

Ours is run regularly, although we had to tweak it down not to interfere
with normal database activity, so it takes several hours each run on the
table. We did that by setting autovacuum_vacuum_scale_factor = 0.05 from
default 0.2.



--
Angular momentum makes the world go 'round.
--------------B6FD58DB0664E90071994DED--