X-Original-To: pgsql-general@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id EC4164762F6 for ; Mon, 12 May 2003 11:41:20 -0400 (EDT) Received: from wolff.to (wolff.to [66.93.249.74]) by postgresql.org (Postfix) with SMTP id 37A2247580B for ; Mon, 12 May 2003 11:41:16 -0400 (EDT) Received: (qmail 5943 invoked by uid 500); 12 May 2003 15:42:43 -0000 Date: Mon, 12 May 2003 10:42:43 -0500 From: Bruno Wolff III To: Adam Sherman Cc: pgsql-general@postgresql.org Subject: Re: Performance Problem Message-ID: <20030512154243.GA5758@wolff.to> Mail-Followup-To: Adam Sherman , pgsql-general@postgresql.org References: <62900000.1052747832@saturn> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <62900000.1052747832@saturn> User-Agent: Mutt/1.5.4i X-Spam-Status: No, hits=-38.0 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_MUTT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200305/355 X-Sequence-Number: 42010 On Mon, May 12, 2003 at 09:57:12 -0400, Adam Sherman wrote: > > BEGIN > while(list) > lookup for existing entry (SELECT) > if not, INSERT > if yes, UPDATE > log a message > COMMIT > > With approx. 30K items the process takes way too long. On the order of 10+ > minutes. > > I notice that the process seems to slow down as it completes more and more > items. ie, the first 10K takes just a few moments while the last 10K takes > most of the time. Note that I'm running test where the only existing > entries will have been inserted in the same transaction. > > I need to know if the bottleneck is PG or higher up so I can go hunting > there. Are there deferred constraints? They are still order n squared. Some fixes went in to 7.3 but the last order n squared issue wasn't fixed until 7.4. There was some discussion of back porting the fix to 7.3.3 (which might be available in about a month) but I am not sure whether or that is going to happen.