From 893632be4e17ccd791cfda17d2e99bb2312f6ff8 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Thu, 7 Sep 2006 22:52:01 +0000 Subject: Clean up logging for extended-query-protocol operations, as per my recent proposal. Parameter logging works even for binary-format parameters, and logging overhead is avoided when disabled. log_statement = all output for the src/test/examples/testlibpq3.c example now looks like LOG: statement: execute : SELECT * FROM test1 WHERE t = $1 DETAIL: parameters: $1 = 'joe''s place' LOG: statement: execute : SELECT * FROM test1 WHERE i = $1::int4 DETAIL: parameters: $1 = '2' and log_min_duration_statement = 0 results in LOG: duration: 2.431 ms parse : SELECT * FROM test1 WHERE t = $1 LOG: duration: 2.335 ms bind to : SELECT * FROM test1 WHERE t = $1 DETAIL: parameters: $1 = 'joe''s place' LOG: duration: 0.394 ms execute : SELECT * FROM test1 WHERE t = $1 DETAIL: parameters: $1 = 'joe''s place' LOG: duration: 1.251 ms parse : SELECT * FROM test1 WHERE i = $1::int4 LOG: duration: 0.566 ms bind to : SELECT * FROM test1 WHERE i = $1::int4 DETAIL: parameters: $1 = '2' LOG: duration: 0.173 ms execute : SELECT * FROM test1 WHERE i = $1::int4 DETAIL: parameters: $1 = '2' (This example demonstrates the folly of ignoring parse/bind steps for duration logging purposes, BTW.) Along the way, create a less ad-hoc mechanism for determining which commands are logged by log_statement = mod and log_statement = ddl. The former coding was actually missing quite a few things that look like ddl to me, and it did not handle EXECUTE or extended query protocol correctly at all. This commit does not do anything about the question of whether log_duration should be removed or made less redundant with log_min_duration_statement. --- doc/src/sgml/config.sgml | 98 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 66 insertions(+), 32 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index 2472c16a3f6..669110a5fda 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -1,4 +1,4 @@ - + Server Configuration @@ -2492,18 +2492,36 @@ SELECT * FROM parent WHERE key = 2400; - Logs the statement and its duration on a single log line if its - duration is greater than or equal to the specified number of - milliseconds. Setting this to zero will print all statements - and their durations. Minus-one (the default) disables the - feature. For example, if you set it to 250 + Causes the duration of each completed statement to be logged + if the statement ran for at least the specified number of + milliseconds. Setting this to zero prints all statement durations. + Minus-one (the default) disables logging statement durations. + For example, if you set it to 250 then all SQL statements that run 250ms or longer will be - logged. Enabling this parameter can be useful in tracking down - unoptimized queries in your applications. This setting is - independent of log_statement and - log_duration. Only superusers can change - this setting. + logged. Enabling this parameter can be helpful in tracking down + unoptimized queries in your applications. + Only superusers can change this setting. + + + For clients using extended query protocol, durations of the Parse, + Bind, and Execute steps are logged independently. + + + + + When using this option together with + , + the text of statements that are logged because of + log_statement will not be repeated in the + duration log message. + If you are not using syslog, it is recommended + that you log the PID or session ID using + + so that you can link the statement message to the later + duration message using the process ID or session ID. + + @@ -2695,14 +2713,30 @@ SELECT * FROM parent WHERE key = 2400; - Causes the duration of every completed statement which satisfies - log_statement to be logged. When using this option, - if you are not using syslog, it is recommended - that you log the PID or session ID using log_line_prefix - so that you can link the statement message to the later - duration message using the process ID or session ID. The default is - off. Only superusers can change this setting. + Causes the duration of every completed statement to be logged. + The default is off. + Only superusers can change this setting. + + + For clients using extended query protocol, durations of the Parse, + Bind, and Execute steps are logged independently. + + + + + When using this option together with + , + the text of statements that are logged because of + log_statement will not be repeated in the + duration log message. + If you are not using syslog, it is recommended + that you log the PID or session ID using + + so that you can link the statement message to the later + duration message using the process ID or session ID. + + @@ -2829,18 +2863,20 @@ SELECT * FROM parent WHERE key = 2400; Controls which SQL statements are logged. Valid values are none, ddl, mod, and all. ddl logs all data definition - commands like CREATE, ALTER, and - DROP commands. mod logs all - ddl statements, plus INSERT, - UPDATE, DELETE, TRUNCATE, - and COPY FROM. PREPARE and - EXPLAIN ANALYZE statements are also logged if their - contained command is of an appropriate type. Protocol-level - prepare, bind, and execute commands are logged only if - log_statement is all. Bind parameter - values are also logged if they are supplied in text - format (literal single quotes are doubled). + statements, such as CREATE, ALTER, and + DROP statements. mod logs all + ddl statements, plus data-modifying statements + such as INSERT, + UPDATE, DELETE, TRUNCATE, + and COPY FROM. + PREPARE, EXECUTE, and + EXPLAIN ANALYZE statements are also logged if their + contained command is of an appropriate type. For clients using + extended query protocol, logging occurs when an Execute message + is received, and values of the Bind parameters are included + (with any embedded single-quote marks doubled). + The default is none. Only superusers can change this setting. @@ -2848,9 +2884,7 @@ SELECT * FROM parent WHERE key = 2400; - The EXECUTE statement is not considered a - ddl or mod statement. Statements that - generate syntax errors are not logged. Set + Statements that generate syntax errors are not logged. Set log_min_error_statement to error to log such statements. -- cgit v1.2.3