Thanks Peter. Patch attached. I added "(secs)" to the ouput: LOG: duration(secs): 0.000257 LOG: duration(secs): 0.000754 LOG: duration(secs): 0.008115 select * from pg_class;
--------------------------------------------------------------------------- Peter Eisentraut wrote: > Bruce Momjian writes: > > > > I think there should be just one "duration: nnn" log entry, printed if > > > either condition holds. > > > > Done. > > Now, if I have log_statement and log_duration on, it logs each statement > twice. The documentation says this: > > log_duration (boolean) > > Causes the duration of every completed statement to be logged. To use > this option, enable log_statement and log_pid so you can link the > statement to the duration using the process ID. > > This needs more thought. > > Also, please put units on all numbers. > > -- > Peter Eisentraut [EMAIL PROTECTED] > -- Bruce Momjian | http://candle.pha.pa.us [EMAIL PROTECTED] | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073
Index: src/backend/tcop/postgres.c =================================================================== RCS file: /cvsroot/pgsql-server/src/backend/tcop/postgres.c,v retrieving revision 1.369 diff -c -c -r1.369 postgres.c *** src/backend/tcop/postgres.c 2 Oct 2003 06:34:04 -0000 1.369 --- src/backend/tcop/postgres.c 4 Oct 2003 02:45:50 -0000 *************** *** 943,948 **** --- 943,949 ---- if (save_log_duration || save_log_min_duration_statement > 0) { long usecs; + bool print_statement; gettimeofday(&stop_t, NULL); if (stop_t.tv_usec < start_t.tv_usec) *************** *** 956,969 **** * Output a duration_statement to the log if the query has exceeded * the min duration, or if we are to print all durations. */ ! if (save_log_duration || ! (save_log_min_duration_statement > 0 && ! usecs >= save_log_min_duration_statement * 1000)) ereport(LOG, ! (errmsg("duration: %ld.%06ld %s", (long) (stop_t.tv_sec - start_t.tv_sec), (long) (stop_t.tv_usec - start_t.tv_usec), ! query_string))); } if (save_log_statement_stats) --- 957,972 ---- * Output a duration_statement to the log if the query has exceeded * the min duration, or if we are to print all durations. */ ! print_statement = (save_log_min_duration_statement > 0 && ! usecs >= save_log_min_duration_statement * 1000); ! ! if (save_log_duration || print_statement) ereport(LOG, ! (errmsg("duration(secs): %ld.%06ld%s%s", (long) (stop_t.tv_sec - start_t.tv_sec), (long) (stop_t.tv_usec - start_t.tv_usec), ! print_statement ? " " : "", ! print_statement ? query_string : ""))); } if (save_log_statement_stats)
---------------------------(end of broadcast)--------------------------- TIP 4: Don't 'kill -9' the postmaster