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 57EE7D1B579 for ; Mon, 17 Nov 2003 21:11:02 +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 48907-10 for ; Mon, 17 Nov 2003 17:10:33 -0400 (AST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) by svr1.postgresql.org (Postfix) with ESMTP id 7FB5BD1B537 for ; Mon, 17 Nov 2003 17:10:31 -0400 (AST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id AD790353E8; Mon, 17 Nov 2003 13:10:27 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id ABE9234D58; Mon, 17 Nov 2003 13:10:27 -0800 (PST) Date: Mon, 17 Nov 2003 13:10:27 -0800 (PST) From: Stephan Szabo To: ow Cc: Jeff , pgsql-admin@postgresql.org Subject: Re: pg_restore and FK constraints with large dbs In-Reply-To: <20031117203824.18689.qmail@web21401.mail.yahoo.com> Message-ID: <20031117130034.M3748@megazone.bigpanda.com> References: <20031117203824.18689.qmail@web21401.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/319 X-Sequence-Number: 11306 On Mon, 17 Nov 2003, ow wrote: > --- Jeff wrote: > > On Mon, 17 Nov 2003 10:40:20 -0800 (PST) > > Stephan Szabo wrote: > > > > > > > > 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. > > > > > PK and FK keys are of "Dkey" domain, "Dkey" domain is mapped to INT4. There's > PK index on 20K pk table, *NO* index on the fk field on 80M fk table. Why no > index on the fk field? Several reasons: (1) app logic does not call for > accessing fk table based solely on the fk (2) fk field is a part of multi-field > AK index (3) unnecessary indexes take space and slow down inserts/updates, > which is a factor for large tables. I assume you're also not modifying the pktable rows (since that would access the fk table based solely on the fk). Does the multi-field index start with fk or some other field? Hmm, the changes in 7.4 for alter probably don't help as much without an index (it saves the cost of making all those executors, but that's might be it). Doing, schema, turning off triggers on the table, data might have worked in general, but if you've got a textual combined dump that'd be a mess for a workaround (it might be reasonable in pg_restore, but I don't tend to use it, so I couldn't say)