Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 209226500CD for ; Tue, 8 Jul 2008 15:34:14 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 56433-07 for ; Tue, 8 Jul 2008 15:34:09 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id B356C6500B8 for ; Tue, 8 Jul 2008 15:34:10 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id m68IY2E1012597; Tue, 8 Jul 2008 14:34:02 -0400 (EDT) To: Achilleas Mantzios cc: pgsql-performance@postgresql.org Subject: Re: syslog performance when logging big statements In-reply-to: <200807081821.57935.achill@matrix.gatewaynet.com> References: <200807081524.47366.achill@matrix.gatewaynet.com> <8675.1215527716@sss.pgh.pa.us> <200807081821.57935.achill@matrix.gatewaynet.com> Comments: In-reply-to Achilleas Mantzios message dated "Tue, 08 Jul 2008 18:21:57 +0300" Date: Tue, 08 Jul 2008 14:34:01 -0400 Message-ID: <12596.1215542041@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200807/72 X-Sequence-Number: 30672 Achilleas Mantzios writes: > Στις Tuesday 08 July 2008 17:35:16 ο/η Tom Lane έγραψε: >> Hmm. There's a function in elog.c that breaks log messages into chunks >> for syslog. I don't think anyone's ever looked hard at its performance >> --- maybe there's an O(N^2) behavior? > Thanx, > i changed PG_SYSLOG_LIMIT in elog.c:1269 from 128 to 1048576 > and i got super fast stderr performance. :) Doesn't seem like a very good solution given its impact on the stack depth right there. Looking at the code, the only bit that looks like repeated work are the repeated calls to strchr(), which would not be an issue in the "typical" case where the very long message contains reasonably frequent newlines. Am I right in guessing that your problematic statement contained megabytes worth of text with nary a newline? If so, we can certainly fix it by arranging to remember the last strchr() result across loop iterations, but I'd like to confirm the theory before doing that work. regards, tom lane