Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 4435F9F9C0E for ; Mon, 17 Sep 2007 07:21:54 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 61314-03 for ; Mon, 17 Sep 2007 07:21:50 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from oxford.xeocode.com (unknown [62.232.55.118]) by postgresql.org (Postfix) with ESMTP id 3D7A69F9BD2 for ; Mon, 17 Sep 2007 07:21:50 -0300 (ADT) Received: from localhost ([127.0.0.1] helo=oxford.xeocode.com) by oxford.xeocode.com with esmtp (Exim 4.67) (envelope-from ) id 1IXDjc-0001QS-L5; Mon, 17 Sep 2007 11:21:44 +0100 To: "Heikki Linnakangas" Cc: "Galantucci Giovanni" , Subject: Re: DELETE queries slow down In-Reply-To: <46EE4676.8040406@enterprisedb.com> (Heikki Linnakangas's message of "Mon\, 17 Sep 2007 10\:18\:46 +0100") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux) X-Draft-From: ("nnimap+mail01.enterprisedb.com:INBOX.performance" 2488) References: <46EE4676.8040406@enterprisedb.com> From: Gregory Stark Organization: EnterpriseDB Date: Mon, 17 Sep 2007 11:21:44 +0100 Message-ID: <873axdpp6v.fsf@oxford.xeocode.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200709/288 X-Sequence-Number: 26833 "Heikki Linnakangas" writes: > Galantucci Giovanni wrote: > >> For 1 or 2 hours we update only one table, and everything goes ok, where >> DELETE last at most 6 or 7 seconds. >> >> Then for a minute we do INSERT on both table, and everything continue >> going ok, with DELETE that last about 10 seconds. >> >> From that moment on, DELETES become timeless, and last for 240 and more >> seconds! What do the inserts and deletes actually look like? Are there subqueries or joins or are they just inserting values and deleting simple where clauses? And are these in autocommit mode or are you running multiple commands in a single transaction? Generally it's faster to run more commands in a single transaction but what I'm worried about is that you may have a transaction open which you aren't committing for a long time. This can stop vacuum from being able to clean up dead space and if it's in the middle of a query can actually cause vacuum to get stuck waiting for the query to finish using the page it's using. -- Gregory Stark EnterpriseDB http://www.enterprisedb.com