Expensive log_line_prefix ?

Started by Sahagian, Davidover 13 years ago5 messagesgeneral
Jump to latest
#1Sahagian, David
david.sahagian@emc.com

In 9.1.x

Are there any "extra" costs to logging all this cool stuff ?

log_line_prefix = '%m %a %u %p %c %m %v %x'

Are any of these expensive ?
Or is the only cost the number of bytes that the textual representation of their values take in the written log file ?

Thanks,
-dvs-

#2Sergey Konoplev
gray.ru@gmail.com
In reply to: Sahagian, David (#1)
Re: Expensive log_line_prefix ?

On Thu, Oct 11, 2012 at 12:19 PM, Sahagian, David
<david.sahagian@emc.com> wrote:

Are there any "extra" costs to logging all this cool stuff ?

log_line_prefix = '%m %a %u %p %c %m %v %x'

The formatting cost only but it is so insignificant that does not
worth bothering with it.

--
Sergey Konoplev

a database and software architect
http://www.linkedin.com/in/grayhemp

Jabber: gray.ru@gmail.com Skype: gray-hemp Phone: +14158679984

#3John R Pierce
pierce@hogranch.com
In reply to: Sergey Konoplev (#2)
Re: Expensive log_line_prefix ?

On 10/11/12 2:57 PM, Sergey Konoplev wrote:

On Thu, Oct 11, 2012 at 12:19 PM, Sahagian, David
<david.sahagian@emc.com> wrote:

Are there any "extra" costs to logging all this cool stuff ?

log_line_prefix = '%m %a %u %p %c %m %v %x'

The formatting cost only but it is so insignificant that does not
worth bothering with it.

i'd think the time spent writing the extra output to the log file would
be the most significant part of it, along with any disk IO contention if
those logs are on the same physical storage as the database.

--
john r pierce N 37, W 122
santa cruz ca mid-left coast

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Sergey Konoplev (#2)
Re: Expensive log_line_prefix ?

Sergey Konoplev <gray.ru@gmail.com> writes:

On Thu, Oct 11, 2012 at 12:19 PM, Sahagian, David
<david.sahagian@emc.com> wrote:

Are there any "extra" costs to logging all this cool stuff ?

log_line_prefix = '%m %a %u %p %c %m %v %x'

The formatting cost only but it is so insignificant that does not
worth bothering with it.

IIRC, %m would imply a gettimeofday call, which might be expensive
depending on your OS and hardware. I think all the other info is
"just sitting around", though.

regards, tom lane

#5Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Tom Lane (#4)
Re: Expensive log_line_prefix ?

Tom Lane escribió:

Sergey Konoplev <gray.ru@gmail.com> writes:

On Thu, Oct 11, 2012 at 12:19 PM, Sahagian, David
<david.sahagian@emc.com> wrote:

Are there any "extra" costs to logging all this cool stuff ?

log_line_prefix = '%m %a %u %p %c %m %v %x'

The formatting cost only but it is so insignificant that does not
worth bothering with it.

IIRC, %m would imply a gettimeofday call, which might be expensive
depending on your OS and hardware. I think all the other info is
"just sitting around", though.

Yeah, and having two %m means two gettimeofday calls.

Also, %c sort of implies %p, so having both is probably just a waste.

One other point is that it's probably a good idea to put in a %q in
there so that processes that don't have things like %v, %x don't have to
print a bunch of zeros (and also to prevent %a, %u from adding spaces
unnecessarily).

--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services