Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 5B4C8650390 for ; Wed, 3 Dec 2008 16:47:07 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 82063-06 for ; Wed, 3 Dec 2008 16:47:02 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.174]) by mail.postgresql.org (Postfix) with ESMTP id F27E864FFBC for ; Wed, 3 Dec 2008 16:47:01 -0400 (AST) Received: by ug-out-1314.google.com with SMTP id k40so3429747ugc.7 for ; Wed, 03 Dec 2008 12:46:58 -0800 (PST) Received: by 10.67.23.5 with SMTP id a5mr2066556ugj.5.1228337218552; Wed, 03 Dec 2008 12:46:58 -0800 (PST) Received: from ?80.223.223.193? (dsl-hkibrasgw2-fedfdf00-193.dhcp.inet.fi [80.223.223.193]) by mx.google.com with ESMTPS id 30sm15584313ugf.13.2008.12.03.12.46.56 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 03 Dec 2008 12:46:57 -0800 (PST) Message-ID: <4936F03E.5040205@enterprisedb.com> Date: Wed, 03 Dec 2008 22:46:54 +0200 Organization: EnterpriseDB User-Agent: Mozilla-Thunderbird 2.0.0.17 (X11/20081018) MIME-Version: 1.0 To: Kynn Jones CC: Andreas Kretschmer , pgsql-performance@postgresql.org Subject: Re: How to profile an "SQL script"? References: <20081203194023.GA8541@tux> In-Reply-To: <20081203194023.GA8541@tux> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit From: Heikki Linnakangas X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200812/30 X-Sequence-Number: 32066 Andreas Kretschmer wrote: > Kynn Jones schrieb: > >> Hi. I have a longish collection of SQL statements stored in a file that I run >> periodically via cron. Running this "script" takes a bit too long, even for a >> cron job, and I would like to streamline it. >> >> Is there a way to tell Postgres to print out, after each SQL statement is >> executed, how long it took to execute? > > Do you run this with psql? You can switch on timing-output, with > \timing. It displays after each statement the run-time for this > statement. See also log_duration and log_min_duration settings. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com