Received: from localhost (unknown [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id ACC839FC038 for ; Wed, 24 Oct 2007 07:44:45 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 08651-01 for ; Wed, 24 Oct 2007 07:44:28 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from el-out-1112.google.com (el-out-1112.google.com [209.85.162.178]) by postgresql.org (Postfix) with ESMTP id CBC219FC027 for ; Wed, 24 Oct 2007 07:44:37 -0300 (ADT) Received: by el-out-1112.google.com with SMTP id m34so52397ele for ; Wed, 24 Oct 2007 03:44:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; bh=ZHuBnWy2WkWvtg2NScjeON7QDkxgU3Dlwft4vYioTmY=; b=lFv0Hpnl9JUtYp2frgBIvRsF1erKV0zzmFGezNKZCTGR0FxgS5vpbY95KY8dQILUhe5oNsOr/PHRFxhYRmdkce8IjHc/XnY64iryUaSFNU0Yn369GTIVAMZomRWRF3Q3420QmuCs/8tmg3qnU/71XGhBP3jDUTtNa6IiRKJJCeU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=BjAdWhiADHLmLBDTbirvtAUpEpeOsUoTpKeynDtk4GwDwuW+KwcB82Wsu4Qck/zDyVuZe8oKa91u544MVPWzEbWc0XYKP1BnmJl5GvXvFDKJKYg5+B4a2FMAXE4TsK8VjmwWstEbCHTsGVvOxdretomBYhK/RBap/NSlaclWSxU= Received: by 10.142.49.4 with SMTP id w4mr36419wfw.1193222675382; Wed, 24 Oct 2007 03:44:35 -0700 (PDT) Received: by 10.142.203.6 with HTTP; Wed, 24 Oct 2007 03:44:35 -0700 (PDT) Message-ID: Date: Wed, 24 Oct 2007 12:44:35 +0200 From: "Giulio Cesare Solaroli" To: pgsql-performance@postgresql.org Subject: Finalizing commit taking very long MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200710/267 X-Sequence-Number: 27289 Hello, I am having a strange latency problem on my instance of Postgres that I don't know how to investigate. I am accessing the db instance using a Java application and the Cayenne mapping framework. Everything works fine, except when it is time to delete a user account (that is a user of the application, not of Postgres). Deleting an account trigger a (sort-of) cascade delete to remove also all the dependent records stored on the db. The cascade constraints are managed by the Cayenne library, and the db receives a list of delete statements for all the rows of the different tables that should be deleted; this is probably not optimal from a db point of view, but is extremely convenient from an application point of view. Anyway, the deletion of all the records is executed without much problems (I had a huge slowdown here a few weeks ago, but I was missing an index on a constraint). Obviously, all the delete statements are grouped into a single transaction; and when it is time to commit this transaction, the db instance takes "forever". Here are some logs taken from the db server: [ lot of delete statements skipped] 2007-10-24 12:13:17 CEST LOG: statement: EXECUTE [PREPARE: DELETE FROM connection.USRCNN WHERE ID_USRCNN = $1] 2007-10-24 12:13:17 CEST LOG: duration: 0.206 ms 2007-10-24 12:13:17 CEST LOG: duration: 0.206 ms statement: EXECUTE [PREPARE: DELETE FROM connection.USRCNN WHERE ID_USRCNN = $1] 2007-10-24 12:13:17 CEST LOG: statement: PREPARE AS DELETE FROM clipperz.USR WHERE ID_USR = $1 2007-10-24 12:13:17 CEST LOG: statement: 2007-10-24 12:13:17 CEST LOG: statement: EXECUTE [PREPARE: DELETE FROM clipperz.USR WHERE ID_USR = $1] 2007-10-24 12:13:17 CEST LOG: duration: 0.761 ms 2007-10-24 12:13:17 CEST LOG: duration: 0.761 ms statement: EXECUTE [PREPARE: DELETE FROM clipperz.USR WHERE ID_USR = $1] 2007-10-24 12:13:17 CEST LOG: statement: 2007-10-24 12:13:17 CEST LOG: statement: EXECUTE [PREPARE: COMMIT] 2007-10-24 12:13:51 CEST LOG: autovacuum: processing database "clipperz_beta" 2007-10-24 12:14:51 CEST LOG: autovacuum: processing database "clipperz_beta" 2007-10-24 12:15:10 CEST LOG: duration: 113300.147 ms 2007-10-24 12:15:10 CEST LOG: duration: 113300.147 ms statement: EXECUTE [PREPARE: COMMIT] As you may notice, the commit phase takes almost 2 full minutes. :-( How can I understand what is going on on that timeframe in order to try to fix it? Thanks for your attention. Best regards, Giulio Cesare PS: I run my development machine on a MacOS, with Postgres running on a Parallels virtual machine. I don't think this really matters for the above problem, but in case ...