Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id F21A81337C07 for ; Mon, 18 Apr 2011 16:16:31 -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 75229-01-4 for ; Mon, 18 Apr 2011 19:16:24 +0000 (UTC) X-Greylist: delayed 00:32:50.333407 by SQLgrey-1.7.6 Received: from mailhub1.renesys.com (mailhub1.ep.renesys.com [195.160.236.248]) by mail.postgresql.org (Postfix) with ESMTP id 1716B1337BDE for ; Mon, 18 Apr 2011 16:15:54 -0300 (ADT) Received: from ops05.psm1.renesys.com (ops05.psm1.renesys.com [10.200.1.25]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mailhub1.renesys.com (Postfix) with ESMTP id 3D551671A4 for ; Mon, 18 Apr 2011 18:12:44 +0000 (UTC) Received: (from rouilj@localhost) by ops05.psm1.renesys.com (8.13.8/8.13.8/Submit) id p3IICf9D016171 for pgsql-performance@postgresql.org; Mon, 18 Apr 2011 18:12:41 GMT Date: Mon, 18 Apr 2011 18:12:41 +0000 From: John Rouillard To: "pgsql-performance@postgresql.org" Subject: Assessing performance of fetches Message-ID: <20110418181241.GF27218@renesys.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) 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: 201104/254 X-Sequence-Number: 43316 Hi all: An application running against a postgres 8.4.5 database under CentOS 5.5 uses cursors (I think via SqlAlchemy). To look for database performance issues I log any query that takes > 2 seconds to complete. I am seeing: 2011-04-16 00:55:33 UTC user@database(3516): LOG: duration: 371954.811 ms statement: FETCH FORWARD 1 FROM c_2aaaaaaeea50_a08 While I obviously have a problem here, is there any way to log the actual select associated with the cursor other than logging all statements? Also once I have the select statement, does the fact that is is associated with a fetch/cursor change the steps I should take in tuning it compared to somebody just issuing a normal select? Thanks for any ideas. -- -- rouilj John Rouillard System Administrator Renesys Corporation 603-244-9084 (cell) 603-643-9300 x 111