Re: fix log_min_duration_statement logic error - Mailing list pgsql-patches
From | Bruce Momjian |
---|---|
Subject | Re: fix log_min_duration_statement logic error |
Date | |
Msg-id | 200310040246.h942khJ23270@candle.pha.pa.us Whole thread Raw |
In response to | Re: fix log_min_duration_statement logic error (Peter Eisentraut <peter_e@gmx.net>) |
Responses |
Re: fix log_min_duration_statement logic error
|
List | pgsql-patches |
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 peter_e@gmx.net > -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (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)
pgsql-patches by date: