Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eAXRo-00018e-FY for pgsql-admin@arkaria.postgresql.org; Fri, 03 Nov 2017 08:35:28 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1eAXRn-0005zt-Je for pgsql-admin@arkaria.postgresql.org; Fri, 03 Nov 2017 08:35:27 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eAXRm-0005zT-ST for pgsql-admin@postgresql.org; Fri, 03 Nov 2017 08:35:26 +0000 Received: from mail-wr0-x231.google.com ([2a00:1450:400c:c0c::231]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1eAXRe-0000EK-At for pgsql-admin@postgresql.org; Fri, 03 Nov 2017 08:35:25 +0000 Received: by mail-wr0-x231.google.com with SMTP id l1so1815216wrc.3 for ; Fri, 03 Nov 2017 01:35:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:mime-version:subject:date:references:to:in-reply-to:message-id; bh=KNqML5aDEvRh50l/1v7YbSvI4Z7o5VhrHxfyu9Js7gg=; b=Qy7nfnqe9VfAPeeZTT9C3VWaMJ/hze+qQTn/hY39rYZ5i5gfizFvXQc72uzoCVJDKW e+ZS29Kr1FgBF3FgRe2fijZicd0tS8edvd52X2B5y76fTY1MXHp8aVO+D7oZghEQgq7Q HlbLQ3Jbr/fR0yTKhGCwwF3oszaHT4GOjWhhVC6dTrkFrB+oO+dGsDVX3+iNhcX5kVrr 9uBKqEQYRT8h2kckQD6S5fGszgyHd6YsGAtCLtPomYCh/ut54tK659UnfV4CiPDF4H6e uVks7qRDczHpA+9LIuVKj+/eh+VnuY0qa+qvLlXAVe4cxiXov15YgMFXPEryhQHc32yn J7xQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:mime-version:subject:date:references:to :in-reply-to:message-id; bh=KNqML5aDEvRh50l/1v7YbSvI4Z7o5VhrHxfyu9Js7gg=; b=lFtduUWy2KVPbr7yLfmyCexzpqiPMarqxwEmpKinfEqmMyRLNwEb750jDcEC1tp0Bd rc7YO16VF2TfkvA1tybMeB0vB91lAxm2Trho0ACbHdNzPVKjLNVg+kB3JNIexr8sY9/c u+NX+FYB/4rBvZOMfVJPuTr+jrswBrJZxmAAsdtRIybzQnW5uFb+2Xy3bZgbpUMjmt6M cpq/1/2aX6+R2pe3wq40fHMv9MRI6a7WSdZIZU0tpTVXPl6vC577v0AwL1xrJrmUdIZI wJe/lskhxPpLyCk8KhnPPJkUZpSOi3y7X1tD0FNghpXttltNcQXlGEDFIHFdiry+qMFU gUdg== X-Gm-Message-State: AMCzsaWr3D0HVCXaHh9WTqX3sx8dcsMV9SlS09H55mXeZUjlvtio/qF+ 48fIMzofwfo+eKL9HdVcmM6savTS X-Google-Smtp-Source: ABhQp+QJV79VoFuK0CTGkWTnUWXourAQ91I3VPOFeJVV7CxTsEN1bIVUmHrAnPW9zipa+Ab7zljJWw== X-Received: by 10.223.138.175 with SMTP id y44mr5741503wry.273.1509698115760; Fri, 03 Nov 2017 01:35:15 -0700 (PDT) Received: from [192.168.1.5] (athedsl-4500096.home.otenet.gr. [94.71.150.136]) by smtp.gmail.com with ESMTPSA id p23sm10383589wrb.76.2017.11.03.01.35.14 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 Nov 2017 01:35:15 -0700 (PDT) From: Vasilis Ventirozos Content-Type: multipart/alternative; boundary="Apple-Mail=_B7207A4F-E715-4959-8210-D4DC43AE51D0" Mime-Version: 1.0 (Mac OS X Mail 11.1 \(3445.4.7\)) Subject: Re: postgresql9.4 aws - no pg_upgrade Date: Fri, 3 Nov 2017 10:35:12 +0200 References: <5c0dd3a9-bee1-13ce-04aa-18571b12e5c4@commandprompt.com> <69c5d778-5d85-dc2e-c70f-5ef95b06db4f@commandprompt.com> <84769c92-3364-1b03-3217-56716e3e9fff@commandprompt.com> To: pgsql-admin In-Reply-To: Message-Id: X-Mailer: Apple Mail (2.3445.4.7) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-admin Precedence: bulk Sender: pgsql-admin-owner@postgresql.org --Apple-Mail=_B7207A4F-E715-4959-8210-D4DC43AE51D0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii > On 3 Nov 2017, at 04:41, bala jayaram wrote: >=20 > Thank you for the response, I ran vacuum db with analyze in stages, it = took 15 hours to complete. Also I noticed auto vacuum enabled for one = of the huge database which is running in parallel to vacuum db . Is = that the reason for running 15 hours ? Because we cannot wait for 15 = hours of outage. What is the best way to address this ? Here's a script i wrote for parallel analyze , it should drop your = analyze time significantly. it is relatively tested and its not very smart but it should work. You = can adjust the split files to have a more equal distribution of workload if you want. Also needs adjustment for rds as its meant to run = locally. Hope this helps a bit. #!/bin/bash # if [ $# -ne 2 ]; then echo "Usage: `basename $0` " exit 0 fi my_psql=3D/opt/postgresql/pgsql/bin/psql db=3D$1 jobs=3D5 port=3D5432 function get_list_of_objects { echo $db $my_psql -d $db -t -p $port -o /tmp/all_objects.sql -c "select 'Vacuum = analyze ' || c.oid::regclass ||' /* manual vacuum-analyze */ ;' \ FROM pg_class c LEFT JOIN pg_class t \ ON c.reltoastrelid =3D t.oid WHERE c.relkind =3D ANY = (ARRAY['r'::"char", 't'::"char", 'm'::"char"]) " } function split_to_jobs { number_of_rows=3D`wc -l < /tmp/all_objects.sql` number_per_file=3D`expr $number_of_rows / $jobs` number_per_file_round_up=3D`expr $number_per_file + 1` split -l $number_per_file /tmp/all_objects.sql /tmp/objects_ } function fix_files { for a in `ls -1 /tmp/objects_*` ; do echo "set timezone TO 'America/New_York'; select '$a = ended at : '||now();">> $a done } function run_vacuum { ls -l /tmp/objects_* for a in `ls -1 /tmp/objects_*` ; do $my_psql -q -X -f $a -d $db -p $port 2>&1 & done } function cleanup { rm /tmp/objects_* /tmp/all_objects.sql || true } cleanup get_list_of_objects; split_to_jobs; fix_files run_vacuum #|grep -v "WARNING" Regards, Vasilis Ventirozos= --Apple-Mail=_B7207A4F-E715-4959-8210-D4DC43AE51D0 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii

On 3 Nov 2017, at 04:41, bala jayaram <balajayaram22@gmail.com> wrote:

Thank you for the response, I = ran vacuum db with analyze in stages, it took 15 hours to = complete.  Also I noticed auto vacuum enabled for one of the  = huge database which is running in parallel to vacuum db . Is that the = reason for running 15 hours ? Because we cannot wait for 15 hours of = outage. What is the best way to address this = ?

Here's a script i wrote for parallel analyze , it should = drop your analyze time significantly.
it is = relatively tested and its not very smart but it should work. You can = adjust the split files to have a more equal distribution of
workload if you want. Also needs adjustment for rds as its = meant to run locally. Hope this helps a bit.

#!/bin/bash
#

if [ $# -ne 2 = ];
then echo "Usage: `basename $0` = <dbname> <jobs> "
exit = 0
fi

my_psql=3D/opt/postgresql/pgsql/bin/psql
db=3D$1
jobs=3D5
port=3D5432

function get_list_of_objects {
echo = $db
$my_psql -d $db -t -p $port -o = /tmp/all_objects.sql -c "select 'Vacuum analyze ' || c.oid::regclass ||' = /* manual vacuum-analyze */ ;' \
FROM = pg_class c LEFT JOIN pg_class t \
ON = c.reltoastrelid =3D t.oid  WHERE c.relkind =3D ANY = (ARRAY['r'::"char", 't'::"char", 'm'::"char"]) "
}

function split_to_jobs {
number_of_rows=3D`wc -l < /tmp/all_objects.sql`
number_per_file=3D`expr $number_of_rows / $jobs`
number_per_file_round_up=3D`expr $number_per_file + = 1`
split -l $number_per_file /tmp/all_objects.sql = /tmp/objects_
}

function fix_files {
for a in `ls -1 /tmp/objects_*` ;
= do echo "set timezone TO 'America/New_York'; select '$a ended at = : '||now();">> $a
done
}

function run_vacuum {
ls -l = /tmp/objects_*
for a in `ls -1 /tmp/objects_*` = ;
do $my_psql -q -X -f $a -d $db -p = $port  2>&1 &
done
}

function cleanup {
rm /tmp/objects_* = /tmp/all_objects.sql || true
}
cleanup
get_list_of_objects;
split_to_jobs;
fix_files
run_vacuum
#|grep -v = "WARNING"


Regards,
Vasilis Ventirozos
= --Apple-Mail=_B7207A4F-E715-4959-8210-D4DC43AE51D0--