Tom,

On 9/8/06, Tom Lane <[EMAIL PROTECTED]> wrote:
It seems like we should either remove the separate log_duration boolean
or make it work as he suggests.  I'm leaning to the second answer now.

Do you want me to propose a patch or do you prefer to work on it
yourself? If so, do we keep the log_duration name or do we change it
to log_all_duration or another more appropriate name?

I attached the little patch I use to apply on our packages. I can work
on it to make it apply to HEAD and update the documentation.

I suppose we should also change the FE/BE protocol logging accordingly
but ISTM you already planned to change it for other reasons.

--
Guillaume
Index: src/backend/tcop/postgres.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/tcop/postgres.c,v
retrieving revision 1.483
diff -u -r1.483 postgres.c
--- src/backend/tcop/postgres.c	4 Apr 2006 19:35:35 -0000	1.483
+++ src/backend/tcop/postgres.c	6 Apr 2006 12:12:00 -0000
@@ -1092,14 +1092,6 @@
 		usecs = (long) (stop_t.tv_sec - start_t.tv_sec) * 1000000 +
 			(long) (stop_t.tv_usec - start_t.tv_usec);
 
-		/* Only print duration if we previously printed the statement. */
-		if (was_logged && save_log_duration)
-			ereport(LOG,
-					(errmsg("duration: %ld.%03ld ms",
-							(long) ((stop_t.tv_sec - start_t.tv_sec) * 1000 +
-								  (stop_t.tv_usec - start_t.tv_usec) / 1000),
-						 (long) (stop_t.tv_usec - start_t.tv_usec) % 1000)));
-
 		/*
 		 * Output a duration_statement to the log if the query has exceeded
 		 * the min duration, or if we are to print all durations.
@@ -1107,6 +1099,7 @@
 		if (save_log_min_duration_statement == 0 ||
 			(save_log_min_duration_statement > 0 &&
 			 usecs >= save_log_min_duration_statement * 1000))
+		{
 			ereport(LOG,
 					(errmsg("duration: %ld.%03ld ms  statement: %s%s",
 							(long) ((stop_t.tv_sec - start_t.tv_sec) * 1000 +
@@ -1114,6 +1107,17 @@
 							(long) (stop_t.tv_usec - start_t.tv_usec) % 1000,
 							query_string,
 							prepare_string ? prepare_string : "")));
+		}
+		else
+		{
+			/* Print duration if we did not print it before. */
+			if (save_log_duration)
+				ereport(LOG,
+						(errmsg("duration: %ld.%03ld ms",
+								(long) ((stop_t.tv_sec - start_t.tv_sec) * 1000 +
+									  (stop_t.tv_usec - start_t.tv_usec) / 1000),
+							 (long) (stop_t.tv_usec - start_t.tv_usec) % 1000)));
+		}
 	}
 
 	if (save_log_statement_stats)
---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Reply via email to