X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 8B8C0D1B8D7 for ; Fri, 31 Oct 2003 18:59:25 +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 51644-04 for ; Fri, 31 Oct 2003 14:58:55 -0400 (AST) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 9B8C7D1B53F for ; Fri, 31 Oct 2003 14:58:53 -0400 (AST) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3850277; Fri, 31 Oct 2003 10:59:35 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Allen Landsidel , pgsql-performance@postgresql.org Subject: Re: index creation order? Date: Fri, 31 Oct 2003 10:58:19 -0800 User-Agent: KMail/1.4.3 References: <6.0.0.22.0.20031031104214.024853b0@pop.hotpop.com> <200310310910.30504.josh@agliodbs.com> <6.0.0.22.0.20031031131506.024864b0@pop.hotpop.com> In-Reply-To: <6.0.0.22.0.20031031131506.024864b0@pop.hotpop.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200310311058.19455.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/805 X-Sequence-Number: 4553 Allen, > I had no idea analyze was playing such a big role in this sense.. I really > thought that other than saving space, it wasn't doing much for tables that > don't have indexes on the. Among other things, ANALYZE tells postgres how many rows are in the table. So if you add a PK constraint after loading 10 million rows without ANALYZE, PostgreSQL is likely to think that there is only one row in the table ... and choose a nested loop or some other really inefficient method of checking for uniqueness. -- Josh Berkus Aglio Database Solutions San Francisco