Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U6Q2v-0007O4-GD for pgsql-bugs@arkaria.postgresql.org; Fri, 15 Feb 2013 18:30:05 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1U6Q2v-00057X-0Q for pgsql-bugs@arkaria.postgresql.org; Fri, 15 Feb 2013 18:30:05 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U6Q2u-000574-Ad for pgsql-bugs@postgresql.org; Fri, 15 Feb 2013 18:30:04 +0000 Received: from www.piware.de ([213.9.93.70]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U6Q2s-0003O4-1C for pgsql-bugs@postgresql.org; Fri, 15 Feb 2013 18:30:03 +0000 Received: from localhost.localdomain (p5DE617AA.dip.t-dialin.net [93.230.23.170]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "Martin Pitt (ThinkPad)", Issuer "piware CA" (verified OK)) by www.piware.de (Postfix) with ESMTPS id 5C25CFB822; Fri, 15 Feb 2013 19:26:19 +0100 (CET) Received: by localhost.localdomain (Postfix, from userid 1000) id 9889A60A71; Fri, 15 Feb 2013 19:29:59 +0100 (CET) Date: Fri, 15 Feb 2013 19:29:59 +0100 From: Martin Pitt To: rtvd@me.com Cc: pgsql-bugs@postgresql.org Subject: Re: BUG #7884: pg_upgradecluster is terribly slow Message-ID: <20130215182959.GA2531@piware.de> Mail-Followup-To: rtvd@me.com, pgsql-bugs@postgresql.org References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org Hello, rtvd@me.com [2013-02-15 17:41 +0000]: > I have tried upgrading a database from 8.4 to 9.1 and pg_upgradecluster is > terribly slow. Please note that this is a Debian/Ubuntu specific bug, pg_upgradecluster is not shipped by upstream PostgreSQL. I admittedly don't have any first-hand experience with migrating large databases, and get very little feedback about it, so thanks for your observations! First of all, Peter has worked on a branch that makes pg_upgradecluster use pg_upgrade, which hopefully will be a lot more performant. > 1. It uses "-Fc". This is bad as it enables compression by default. Which is > pointless and wastes CPU power. The tar format (-Ft) has also been supported since at least 8.4 (that's the earliest version which is still supported in Debian/Ubuntu), and documentation says it's not compressed. If you replace -Fc with -Ft, do you see a significant performance increase? > 2. It seems to migrate the schema first and only then it moves data. This is > bad as indices are being re-built when the data is finally poured in. At least in earlier versions pg_dumpall wasn't able to dump BLOBs, and the manpage doesn't indicate otherwise for 9.2 either. AFAIK this just supports the plain SQL text format. I don't believe pg_dumpall would avoid the rebuilding of incides? > 3. The migration does not happen within a transaction. > 1. migrate the schema pg_upgradecluster does that, too. > 2. drop all databases (leaving roles in) > 3. re-creating the databases (without any content) Out of interest, why does that help? > 4. for each database run pg_dump | psql --single-transaction > As written above, I don't want to use the text format and psql, but pg_restore also supports --single-transaction since at least 8.4. The question which I'm not sure about is whether it's ok to use --single-transaction even for very large databases. I. e. is piling up gigabytes of data in a transaction and committing it all in the end always more efficient than the default mode (which I assume will use one transaction by row)? Is that a safe thing to do, or could one run into out-of-memory conditions? http://people.canonical.com/~pitti/tmp/pg_upgradecluster is a version with these two changes: pg_restore --single-transaction and using the tar format. Perhaps you can try this, and compare performance? Thanks, Martin -- Martin Pitt | http://www.piware.de Ubuntu Developer (www.ubuntu.com) | Debian Developer (www.debian.org) -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs