X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id ED407D1B8F5 for ; Fri, 31 Oct 2003 16:33:03 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 27037-04 for ; Fri, 31 Oct 2003 12:32:33 -0400 (AST) Received: from trade-india.com (ns5.trade-india.com [66.234.10.13]) by svr1.postgresql.org (Postfix) with SMTP id 27663D1B54F for ; Fri, 31 Oct 2003 12:32:32 -0400 (AST) Received: (qmail 3924 invoked from network); 31 Oct 2003 16:33:44 -0000 Received: from unknown (HELO trade-india.com) (203.145.130.142) by ns5.trade-india.com with SMTP; 31 Oct 2003 16:33:44 -0000 Message-ID: <3FA473C5.3020509@trade-india.com> Date: Sat, 01 Nov 2003 22:02:29 -0500 From: Rajesh Kumar Mallah User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030630 X-Accept-Language: en-us, en MIME-Version: 1.0 To: "PGSQL List (E-mail)" Subject: fishing out LOG: duration lines from the logfile. Content-Type: multipart/alternative; boundary="------------060806090008000004050405" X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=1.9 tagged_above=0.0 required=5.0 tests=BAYES_20, DATE_IN_FUTURE_24_48, HTML_20_30, HTML_FONT_COLOR_RED, USER_AGENT_MOZILLA_UA X-Spam-Level: * X-Archive-Number: 200310/400 X-Sequence-Number: 10961 This is a multi-part message in MIME format. --------------060806090008000004050405 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Hi, I think its not going to a trivial task to take out only the LOG duration lines from a PostgreSQL logfile. We need to extract the duration and the actual statement. I think i will put a custom delimeters around the statements for the time being so that the log parser can parse it unambigiously. Is there any better method? Regds Mallah. Example Log file: LOG: duration: 3.725 ms statement: SELECT c.oid, n.nspname, c.relname FROM pg_catalog.pg_class c LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace WHERE pg_catalog.pg_table_is_visible(c.oid) AND c.relname ~ '^users$' ORDER BY 2, 3; other log messages other log messages other log messages LOG: duration: 0.705 ms statement: SELECT relhasindex, relkind, relchecks, reltriggers, relhasrules FROM pg_catalog.pg_class WHERE oid = '17411' LOG: duration: 5.929 ms statement: SELECT a.attname, pg_catalog.format_type(a.atttypid, a.atttypmod), a.attnotnull, a.atthasdef, a.attnum FROM pg_catalog.pg_attribute a WHERE a.attrelid = '17411' AND a.attnum > 0 AND NOT a.attisdropped ORDER BY a.attnum LOG: duration: 0.799 ms statement: SELECT substring(d.adsrc for 128) FROM pg_catalog.pg_attrdef d WHERE d.adrelid = '17411' AND d.adnum = 1 LOG: duration: 0.965 ms statement: SELECT substring(d.adsrc for 128) FROM pg_catalog.pg_attrdef d WHERE d.adrelid = '17411' AND d.adnum = 31 LOG: duration: 0.998 ms statement: SELECT substring(d.adsrc for 128) FROM pg_catalog.pg_attrdef d WHERE d.adrelid = '17411' AND d.adnum = 33 LOG: duration: 2.288 ms statement: SELECT c2.relname, i.indisprimary, i.indisunique, pg_catalog.pg_get_indexdef(i.indexrelid) FROM pg_catalog.pg_class c, pg_catalog.pg_class c2, pg_catalog.pg_index i WHERE c.oid = '17411' AND c.oid = i.indrelid AND i.indexrelid = c2.oid ORDER BY i.indisprimary DESC, i.indisunique DESC, c2.relname LOG: duration: 2.288 ms statement: SELECT c2.relname, i.indisprimary, i.indisunique, pg_catalog.pg_get_indexdef(i.indexrelid) FROM pg_catalog.pg_class c, pg_catalog.pg_class c2, pg_catalog.pg_index i WHERE c.oid = '17411' AND c.oid = i.indrelid AND i.indexrelid = c2.oid ORDER BY i.indisprimary DESC, i.indisunique DESC, c2.relname :statement end (<-- custom delimit) --------------060806090008000004050405 Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit
Hi,

I think its not going to a trivial task to take out only the LOG duration
lines from a PostgreSQL logfile. We need to extract the duration and
the actual statement. I think i will put a custom delimeters around the
statements for the time being so that the log parser can parse it
unambigiously. Is there any better method?


Regds
Mallah.


Example Log file:


LOG:  duration: 3.725 ms  statement: SELECT c.oid,
          n.nspname,
          c.relname
        FROM pg_catalog.pg_class c
             LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
        WHERE pg_catalog.pg_table_is_visible(c.oid)
              AND c.relname ~ '^users$'
        ORDER BY 2, 3;

other log messages
other log messages
other log messages


LOG:  duration: 0.705 ms  statement: SELECT relhasindex, relkind, relchecks, reltriggers, relhasrules
        FROM pg_catalog.pg_class WHERE oid = '17411'
LOG:  duration: 5.929 ms  statement: SELECT a.attname,
          pg_catalog.format_type(a.atttypid, a.atttypmod),
          a.attnotnull, a.atthasdef, a.attnum
        FROM pg_catalog.pg_attribute a
        WHERE a.attrelid = '17411' AND a.attnum > 0 AND NOT a.attisdropped
        ORDER BY a.attnum
LOG:  duration: 0.799 ms  statement: SELECT substring(d.adsrc for 128) FROM pg_catalog.pg_attrdef d
        WHERE d.adrelid = '17411' AND d.adnum = 1
LOG:  duration: 0.965 ms  statement: SELECT substring(d.adsrc for 128) FROM pg_catalog.pg_attrdef d
        WHERE d.adrelid = '17411' AND d.adnum = 31
LOG:  duration: 0.998 ms  statement: SELECT substring(d.adsrc for 128) FROM pg_catalog.pg_attrdef d
        WHERE d.adrelid = '17411' AND d.adnum = 33
LOG:  duration: 2.288 ms  statement: SELECT c2.relname, i.indisprimary, i.indisunique, pg_catalog.pg_get_indexdef(i.indexrelid)
        FROM pg_catalog.pg_class c, pg_catalog.pg_class c2, pg_catalog.pg_index i
        WHERE c.oid = '17411' AND c.oid = i.indrelid AND i.indexrelid = c2.oid
        ORDER BY i.indisprimary DESC, i.indisunique DESC, c2.relname



LOG:  duration: 2.288 ms  statement: SELECT c2.relname, i.indisprimary, i.indisunique, pg_catalog.pg_get_indexdef(i.indexrelid)
        FROM pg_catalog.pg_class c, pg_catalog.pg_class c2, pg_catalog.pg_index i
        WHERE c.oid = '17411' AND c.oid = i.indrelid AND i.indexrelid = c2.oid
        ORDER BY i.indisprimary DESC, i.indisunique DESC, c2.relname :statement end (<-- custom delimit)


--------------060806090008000004050405--