Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id B7B1F1337B78 for ; Wed, 20 Oct 2010 17:30:29 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 73577-07 for ; Wed, 20 Oct 2010 20:30:21 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from lpo-relay-05.vmsinfo.com (lpo-relay-05.vmsinfo.com [216.169.137.116]) by mail.postgresql.org (Postfix) with ESMTP id 4BEA21337B50 for ; Wed, 20 Oct 2010 17:30:20 -0300 (ADT) X-IronPort-AV: E=Sophos;i="4.57,356,1283745600"; d="scan'208";a="29514665" Received: from unknown (HELO lpo-mailbox-01.vmsinfo.com) ([216.169.137.252]) by lpo-relay-05.vmsinfo.com with ESMTP; 20 Oct 2010 16:30:20 -0400 Received: from [10.101.43.35] (unknown [216.169.135.235]) by lpo-mailbox-01.vmsinfo.com (Postfix) with ESMTP id EF0667D00B; Wed, 20 Oct 2010 16:30:19 -0400 (EDT) Message-ID: <4CBF515B.1060704@vmsinfo.com> Date: Wed, 20 Oct 2010 16:30:19 -0400 From: Mladen Gogala Organization: VMS User-Agent: Thunderbird 2.0.0.24 (X11/20100411) MIME-Version: 1.0 To: Dimi Paun CC: "pgsql-performance@postgresql.org" Subject: Re: What is postmaster doing? References: <1287600255.18151.58.camel@dimi.lattica.com> In-Reply-To: <1287600255.18151.58.camel@dimi.lattica.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201010/322 X-Sequence-Number: 40740 Dimi Paun wrote: > Folks, > > I am running into a problem with the postmaster: from time to time, it > runs for a long time. E.g., from top: > > 23425 postgres 20 0 22008 10m 10m R 99.9 0.5 21:45.87 postmaster > > I'd like to figure out what it is doing. How can I figure out what > statement causes the problem? > > is there a way I can log all SQL statements to a file, together with the > time it took to execute them? > > You can do one better: you can even explain the statements, based on the execution time. There is a module called auto explain: http://www.postgresql.org/docs/8.4/static/auto-explain.html For the log files, you can parse them using pgfouine and quickly find out the most expensive SQL statements. -- Mladen Gogala Sr. Oracle DBA 1500 Broadway New York, NY 10036 (212) 329-5251 http://www.vmsinfo.com The Leader in Integrated Media Intelligence Solutions