X-Original-To: pgsql-bugs-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4467953237 for ; Wed, 23 Mar 2005 19:47:13 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 99762-09 for ; Wed, 23 Mar 2005 19:46:53 +0000 (GMT) Received: from floppy.pyrenet.fr (unknown [194.116.145.2]) by svr1.postgresql.org (Postfix) with ESMTP id 4B2875336E for ; Wed, 23 Mar 2005 19:46:52 +0000 (GMT) Received: by floppy.pyrenet.fr (Postfix, from userid 106) id E940430EA1; Wed, 23 Mar 2005 20:46:53 +0100 (MET) From: Andrew - Supernews X-Newsgroups: pgsql.bugs Subject: Re: BUG #1552: massive performance hit between 7.4 and 8.0.1 Date: Wed, 23 Mar 2005 19:46:50 -0000 Organization: http://www.supernews.com - all your nntp are belong to us Message-ID: References: <20050318232102.08FA0F0E5D@svr2.postgresql.org> <1111567230.11750.596.camel@localhost.localdomain> <4241C1DF.2020000@deepsky.com> Reply-To: andrew@supernews.com User-Agent: slrn/0.9.8.0 (FreeBSD) X-Complaints-To: abuse@supernews.com Lines: 20 To: pgsql-bugs@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200503/204 X-Sequence-Number: 11324 On 2005-03-23, Keith Browne wrote: > One other thing which puzzled me: as a test, I tried modifying our > script to spit out raw SQL statements instead of connecting to the > database and performing the inserts itself. Normally, our script > populates two tables in one pass, and then populates the third and > fourth tables in a second pass. I massaged the SQL by hand to group the > inserts together by table, so that the first table would be entirely > populated, then the second, etc. When I ran this SQL script by piping > it straight into psql, it finished in about four minutes. Changing the order so that the referenced table is fully populated, or at least populated with more than a handful of pages of rows, before doing _any_ insert on a referencing table in the same session will avoid the misplan of the FK trigger queries, because when the first insert happens on a referencing table, there will be no reason for the planner to prefer a sequential scan. So this result is not surprising at all. -- Andrew, Supernews http://www.supernews.com - individual and corporate NNTP services