X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id AADB8D1B538 for ; Mon, 17 Nov 2003 18:41:07 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 26085-07 for ; Mon, 17 Nov 2003 14:40:36 -0400 (AST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) by svr1.postgresql.org (Postfix) with ESMTP id F19CCD1C4D6 for ; Mon, 17 Nov 2003 14:40:34 -0400 (AST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 137D3353B9; Mon, 17 Nov 2003 10:40:20 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 1259835302; Mon, 17 Nov 2003 10:40:20 -0800 (PST) Date: Mon, 17 Nov 2003 10:40:20 -0800 (PST) From: Stephan Szabo To: ow Cc: pgsql-admin@postgresql.org Subject: Re: pg_restore and FK constraints with large dbs In-Reply-To: <20031117041435.13499.qmail@web21402.mail.yahoo.com> Message-ID: <20031117103655.W99532@megazone.bigpanda.com> References: <20031117041435.13499.qmail@web21402.mail.yahoo.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200311/315 X-Sequence-Number: 11302 On Sun, 16 Nov 2003, ow wrote: > --- ow wrote: > > Perhaps I should clarify. > > > > First, I ran pg_dump to extract schema and data *together*. Then I ran > > pg_restore to restore the db. It took about 1 hour to create tables and copy > > the data, then about 40 min to create indexes, then pg_restore spent 4.5 > > hours > > checking one (1) FK constraint (80M table with FKs against 20K table with > > PKs) > > > > 4.5 hours to check one FK constraint - this is what I meant by bad > > performance. > > I'm looking for a way to suspend FK checks since data is coming from pg_dump > > and, hence, it's clean. > > > > No solution? Thanks By the way, what does your schema look like? I created an 80M row fk table and 20K row pk table with an int4 key between them and indexes on the two key fields. It took about 25 minutes on my not terribly fast system using 7.4b5 to make the foreign key between them. It might have been faster if I'd raised sort_mem to something larger than 8192.