Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id CB3266341DB for ; Tue, 10 Mar 2009 20:25:06 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 86579-03 for ; Tue, 10 Mar 2009 20:24:59 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from n70.bullet.mail.sp1.yahoo.com (n70.bullet.mail.sp1.yahoo.com [98.136.44.38]) by mail.postgresql.org (Postfix) with SMTP id C9729634551 for ; Tue, 10 Mar 2009 20:25:00 -0300 (ADT) Received: from [69.147.84.144] by n70.bullet.mail.sp1.yahoo.com with NNFMP; 10 Mar 2009 23:24:58 -0000 Received: from [67.195.9.81] by t6.bullet.mail.sp1.yahoo.com with NNFMP; 10 Mar 2009 23:24:58 -0000 Received: from [67.195.9.105] by t1.bullet.mail.gq1.yahoo.com with NNFMP; 10 Mar 2009 23:24:58 -0000 Received: from [127.0.0.1] by omp109.mail.gq1.yahoo.com with NNFMP; 10 Mar 2009 23:24:58 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 129343.31687.bm@omp109.mail.gq1.yahoo.com Received: (qmail 35657 invoked by uid 60001); 10 Mar 2009 23:24:57 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1236727497; bh=zTKkbQHEwWyRvnJuh3vcrYsgYsd4zCBvShWEjorip2k=; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:MIME-Version:Content-Type; b=b0MCuPErzc/UEl3Eos6WS9x4GYQIQS4j579iLcBZ/rjLPw5fTpQOzpivaidtbdF5RbKTYli4bErOxdAkc461DNrMP5DH6hi95QCRcKEVJFEenY7IDRBEkrFWWPxe8dmr1AadkjdskAjxk7aE24GIK9intLCvmJCC7gBrhtztciE= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:MIME-Version:Content-Type; b=ICdFPKfytcm1T7o3evShl/AlOXqSU95FMPNvyLJy58ZEzw0PEptHmf8IdQfiXTRoJEblK89adDlRwBg/iUZNAwlZGf43/QuzqLdRHiZNzITgQC2NS8Fc6VAJPCH2fK9UazUrvnbFWGDvGEobzTUISFrCYfRz1Z9u84VSbZvW5CM=; Message-ID: <798506.30088.qm@web111308.mail.gq1.yahoo.com> X-YMail-OSG: 7fEOElUVM1n8lbMSc6ccDJoxKBnZ4YHjpp08huq2qrdFnI29oEMFowYKxUJebGVwboGL2DurxUiO9scGzKWyXK5.ngyDS0ax7OmRcn1vxcC5GODayqHUhhG6_6p7O_2MU5Dq4JTzhKXT7aXxnpWQ6zgdscmgWECr7HIDk5RvphJExy.MlzTJXlSovDim_MvkPFiq21xopeqBa9mmCxR45JpPKW7j.L62cSNwPWTOQZKyGtxmGWwIgjub7AXSSvFvdlwAbq8LTeHlLMIe Received: from [98.166.112.215] by web111308.mail.gq1.yahoo.com via HTTP; Tue, 10 Mar 2009 16:24:57 PDT X-Mailer: YahooMailRC/1277.29 YahooMailWebService/0.7.289.1 Date: Tue, 10 Mar 2009 16:24:57 -0700 (PDT) From: Jessica Richard Subject: how to figure out how long a query takes in the pg log file... To: pgsql-admin@postgresql.org MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-1046998474-1236727497=:30088" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 200903/139 X-Sequence-Number: 31639 --0-1046998474-1236727497=:30088 Content-Type: text/plain; charset=us-ascii I need to identify the slowest queries by analyzing the postgre log file. By the following log_line_prefix set up, I can see all the query contents and I can see the duration times: log_line_prefix = '%u %d %h %m %c %x ' .. .. postgres testdb [local] 2009-03-10 14:36:35.110 EDT 49b6b31a.8ad 30898958 DETAIL: ! system usage stats: postgres testdb [local] 2009-03-10 14:36:35.110 EDT 49b6b31a.8ad 30898958 LOG: statement: select count(*) from testtable; postgres testdb [local] 2009-03-10 14:36:35.111 EDT 49b6b31a.8ad 30898958 LOG: PARSE ANALYSIS STATISTICS postgres testdb [local] 2009-03-10 14:36:35.111 EDT 49b6b31a.8ad 30898958 DETAIL: ! system usage stats: .. postgres testdb [local] 2009-03-10 14:36:47.935 EDT 49b6b31a.8ad 0 LOG: duration: 12825.670 ms But I am unable to link he duration time taken by the original query. Even though I used the session id %c and the transaction id %x, when it comes to the duration line, the transaction id is always "0" -- I can't match it to the query line that has a non-zero transaction id. I ideally I expect to see something in common between the duration line and the query line so that I can group them together --- then I will be able to see the slowest queries and look for the tuning options from there. Since all the queries take different amounts of time to finish, the duration time showed up few lines after the query line does not mean it was the time that query took. The same session id can have many different transaction ids. Could some one out there help me on this? Thanks a lot, Jessica --0-1046998474-1236727497=:30088 Content-Type: text/html; charset=us-ascii
I need to identify the slowest queries by analyzing the postgre log file.

By the following log_line_prefix set up, I can see all the query contents and I can see the duration times:

log_line_prefix = '%u %d %h %m %c %x '     

.
.
postgres testdb [local] 2009-03-10 14:36:35.110 EDT 49b6b31a.8ad 30898958 DETAIL:  ! system usage stats:
postgres testdb [local] 2009-03-10 14:36:35.110 EDT 49b6b31a.8ad 30898958 LOG:  statement: select count(*) from testtable;
postgres testdb [local] 2009-03-10 14:36:35.111 EDT 49b6b31a.8ad 30898958 LOG:  PARSE ANALYSIS STATISTICS
postgres testdb [local] 2009-03-10 14:36:35.111 EDT 49b6b31a.8ad 30898958 DETAIL:  ! system usage stats:
.
postgres testdb [local] 2009-03-10 14:36:47.935 EDT 49b6b31a.8ad 0 LOG:  duration: 12825.670 ms


But I am unable to link he duration time taken by the original query. Even though I used the session id %c and the transaction id %x, when it comes to the duration line, the transaction id is always "0" -- I can't match it to the query line that has a non-zero transaction id.

I ideally I expect to see something in common between the duration line and the query line so that I can group them together --- then I will be able to see the slowest queries and look for the tuning options from there. Since all the queries take different amounts of time to finish, the duration time showed up few lines after the query line does not mean it was the time that query took.  The same session id can have many different transaction ids.

Could some one out there help me on this?

Thanks a lot,
Jessica

--0-1046998474-1236727497=:30088--