From: Ron <ronljohnsonjr@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: Recommendation to run vacuum FULL in parallel
Date: Thu, 11 Apr 2019 02:01:50 -0500
Message-ID: <b35d52ac-6911-53b3-1aa0-f3fc32d6d02b@gmail.com> (raw)
In-Reply-To: <CALvqh4rATReNKQLmrU0xHe5tpr_EFO5h2-n-w-_QFwYmdGVbbg@mail.gmail.com>
References: <9ed59ae2-6eb1-549d-eb05-d1546fd11515@mail.ru>
<CAHOFxGqzLdRc+0dNp9q6q2oBCYUiQCmzYm8ma3Cng5m1+1tnZQ@mail.gmail.com>
<a04bde8b-867f-1daf-08c7-dd9bb6263cb3@mail.ru>
<CALvqh4qXSQ4nFG16hGzbEkPTfORih3tuOhyaT9P7RxVKdy6O6Q@mail.gmail.com>
<MN2PR19MB2575026251A1DF43BEDC5066A4500@MN2PR19MB2575.namprd19.prod.outlook.com>
<CALvqh4rATReNKQLmrU0xHe5tpr_EFO5h2-n-w-_QFwYmdGVbbg@mail.gmail.com>
Look also at pg_stat_all_tables.n_dead_tup for tables which are candidates
for vacuuming.
On 4/10/19 11:49 PM, Perumal Raj wrote:
> Thanks Kevin for the inputs,
>
> In my Case there are 500+ Tables and biggest chunk 30GB ( Table only) +
> its indexes.
> So i have created 6 batches and executed in parallel . All my scripts
> completed in 2 Hours and my DB size came down from 500GB to 300GB.
>
> Yes i do see CPU spike, But i did whole activity with full apps down time.
>
> Going forward i am going to run vacuum daily basis to maintain the DB size.
>
> Also Table/DB Age came down drastically.
>
> Thanks
> Raj
>
> On Thu, Apr 4, 2019 at 12:53 PM Kevin Brannen <KBrannen@efji.com
> <mailto:KBrannen@efji.com>> wrote:
>
> *From:* Perumal Raj <perucinci@gmail.com <mailto:perucinci@gmail.com>>
>
> **
>
> 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 ?
>
> We have a small bash script (see below) that get the list of tables
> and their sizes, sorted smallest to largest, and do “vacuum full” one
> at a time because (as someone else pointed out) this is very I/O
> intensive. That order also helps to ensure we finish because some of
> our installs are at the edge of running out of space (an issue we’re
> dealing with). I probably wouldn’t have a problem doing 2 at a time,
> but we do this in the middle of the night when activity is lowest and
> it only takes 1-2 hours, so we’re good with it. It sounds like you
> have a lot more data though.
>
> You might also consider putting the data into different tablespaces
> which are spread over multiple disks to help I/O. If you can, use SSD
> drives, they help with speed quite a bit. 😊
>
> Don’t worry about table dependencies. This is a physical operation,
> not a data operation.
>
> HTH,
>
> Kevin
>
> $PGPATH/psql -t -c "
>
> WITH s AS (SELECT nspname || '.' || relname AS TABLE_NAME,
> pg_total_relation_size(c.oid) AS total_bytes
>
> FROM pg_class c
>
> LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
>
> WHERE relkind = 'r' AND nspname NOT IN (
> 'pg_catalog', 'information_schema' )
>
> ORDER BY 2 )
>
> SELECT table_name FROM s
>
> " |
>
> while read t ; do echo "" ; echo $t; $PGPATH/vacuumdb -w -z -f -t
> $t ; done
>
> ###
>
> This e-mail transmission, and any documents, files or previous e-mail
> messages attached to it, may contain confidential information. If you
> are not the intended recipient, or a person responsible for delivering
> it to the intended recipient, you are hereby notified that any
> disclosure, distribution, review, copy or use of any of the
> information contained in or attached to this message is STRICTLY
> PROHIBITED. If you have received this transmission in error, please
> immediately notify us by reply e-mail, and destroy the original
> transmission and its attachments without reading them or saving them
> to disk. Thank you.
>
--
Angular momentum makes the world go 'round.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: ronljohnsonjr@gmail.com
Subject: Re: Recommendation to run vacuum FULL in parallel
In-Reply-To: <b35d52ac-6911-53b3-1aa0-f3fc32d6d02b@gmail.com>
References: <9ed59ae2-6eb1-549d-eb05-d1546fd11515@mail.ru> <CAHOFxGqzLdRc+0dNp9q6q2oBCYUiQCmzYm8ma3Cng5m1+1tnZQ@mail.gmail.com> <a04bde8b-867f-1daf-08c7-dd9bb6263cb3@mail.ru> <CALvqh4qXSQ4nFG16hGzbEkPTfORih3tuOhyaT9P7RxVKdy6O6Q@mail.gmail.com> <MN2PR19MB2575026251A1DF43BEDC5066A4500@MN2PR19MB2575.namprd19.prod.outlook.com> <CALvqh4rATReNKQLmrU0xHe5tpr_EFO5h2-n-w-_QFwYmdGVbbg@mail.gmail.com> <b35d52ac-6911-53b3-1aa0-f3fc32d6d02b@gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox