Re: fix log_min_duration_statement logic error

Поиск
Список
Период
Сортировка
От Bruce Momjian
Тема Re: fix log_min_duration_statement logic error
Дата
Msg-id 200310082113.h98LDpJ01772@candle.pha.pa.us
обсуждение исходный текст
Ответ на Re: fix log_min_duration_statement logic error  (Peter Eisentraut <peter_e@gmx.net>)
Список pgsql-patches
Peter Eisentraut wrote:
> Bruce Momjian writes:
>
> > > Imagine someone always having log_statement on and doing some sort of
> > > aggregate query counting, say like grep '^LOG: query:' | wc -l.  Now that
> > > someone (or maybe the admin on the night shift, to make it more dramatic)
> > > also turns on log_min_statement_duration (or whatever it's spelled), say
> > > to find the slowest queries: grep '^LOG: duration:' | sort -xyz | head
> > > -10.  In order to guarantee the consistency of both results, you'd have to
> > > log each query twice in this case.
> >
> > I guess.
>
> Can we agree to this?
>
> * If log_statement is on, then we log
>
> query: %s
>
> (Should it be "statement: %s"?)  %s has newlines suitable escaped; exactly

Yes, it should be 'statement'.

> how is independent of this discussion.

People didn't like the newlines changed because it makes large queries
hard to read (all on one line), and we had to double-escape backslashes,
meaning the logged query had different backslashing from the original.

> * If log_duration is on, then we log
>
> duration: x.xxx ms
>
> The user can use log_pid to link it to the statement.  (If the user
> doesn't like this, he can use log_min_duration_statement=0.)

Exactly.  log_min_duration_statement=0 delays the print of the statement
until it completes, but it prints them together.

> * If log_min_duration_statement is triggered, then we log
>
> duration: x.xxx ms; query: %s
>
> * If log_statement is on and log_min_duration_statement is triggered, then
> we (pick one):
>
> (a) log both as per above, or

I think we have to log both because perhaps they want the query printed
before it completes.

> (b) log only log_min_duration_statement
>
> * If log_duration is on and log_min_duration_statement is triggered, then
> we (pick one):
>
> (a) log both as per above, or
> (b) log only log_min_duration_statement

Good point.  Right now we do only:

    duration: x.xxx ms; query: %s

This seems wrong because it isn't consistent with log_statement.  Glad
you pointed that out.  The only argument for printing one one is that
there isn't any value to printing the duration separately, because it
isn't printing before the query.  However, for consistency, I think you
are right we should print both.

--
  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

В списке pgsql-patches по дате отправления:

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: Re: fix log_min_duration_statement logic error
Следующее
От: Tom Lane
Дата:
Сообщение: Re: [HACKERS] Cannot dump/restore text value \N