Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o0u48-0005FO-TV for pgsql-hackers@arkaria.postgresql.org; Tue, 14 Jun 2022 00:05:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1o0u47-0008LF-OZ for pgsql-hackers@arkaria.postgresql.org; Tue, 14 Jun 2022 00:05:51 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o0u47-0008L6-0j for pgsql-hackers@lists.postgresql.org; Tue, 14 Jun 2022 00:05:51 +0000 Received: from xvm-110-146.dc2.ghst.net ([46.226.110.146] helo=fetter.org) by makus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1o0u44-0007dH-BV for pgsql-hackers@postgresql.org; Tue, 14 Jun 2022 00:05:50 +0000 Received: by fetter.org (Postfix, from userid 1001) id 4C5EA4186E; Tue, 14 Jun 2022 00:05:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fetter.org; s=default; t=1655165146; bh=C+LAmUWmQj3bwyl3jzS3s5vsxfJTl7ZGHA1hxS68iRo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=YQNRcv9TONF2EYU8w3F19DUs4G7oxzD5vJVx+KMrik1me0x2XtndM3kBt+U6eQ0Ze f4073BXNz+OToOizfdr7yU9+GG6+IL9qB+xqpOvip5BAjMPLqjpQefKG50pRJLSdQV tn9plEk5Xgq1d5XwtFamvAS54I/2fVhA7SAJ/D281/n1nvDvfFOOBFV/FPTr05Am3u I8nZZ/PS9YXfPKqqqXS0pkyCQknoKAzlDIoRTwQeJ9K3cQ74gJCo+DaHlN8KHG6Dtt YCDlY/xWdL6n9mgS7A/88Upsoy3rr6s7cuFBiBM0sGYbBWV69feYUNIAUBuZHcUJY+ wTsvpyJarXbQg== Date: Tue, 14 Jun 2022 00:05:45 +0000 From: David Fetter To: Tom Lane Cc: Robert Haas , PostgreSQL Development Subject: Re: Finer grain log timestamps Message-ID: <20220614000545.GE12494@fetter.org> References: <20220508204451.GC11333@fetter.org> <3920623.1655151762@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3920623.1655151762@sss.pgh.pa.us> User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, Jun 13, 2022 at 04:22:42PM -0400, Tom Lane wrote: > Robert Haas writes: > > On Sun, May 8, 2022 at 4:45 PM David Fetter wrote: > >> Please find attached a patch to change the sub-second granularity of > >> log timestamps from milliseconds to microseconds. > > > Why is this a good idea? > > I can imagine that some people would have a use for microsecond > resolution in log files, and I can also imagine that as machines > get faster more people will want that. Your imagination matches situations I've seen in production where there was some ambiguity as to what happened when inside a millisecond boundary, and I'm sure I'm not alone in this. I've gotten this request from at least three people who to my knowledge knew nothing about each other, and as I recall, the first time someone brought it up to me was over five years back. > As against that, this will bloat log files by a non-microscopic > amount, and it's pretty likely to break some log-scanning tools too. Three bytes per line, and log-scanning parsers that finicky are already breaking all the time, respectively. > It's unclear to me that that's a tradeoff we should force on > everyone. The tradeoff we're forcing on people at the moment is a loss of precision they didn't ask for, implemented by some extra instructions they didn't ask us to execute in a part of the code that's a hot path at exactly the times when the machine is busiest. > I think a proposal less likely to have push-back would be to invent > a different log_line_prefix %-escape to produce microseconds. > Sadly, "%u" is already taken, but perhaps we could use "%U"? > > A different line of thought is to extend %t to provide a precision > field a la sprintf, so that for example "%.3t" is equivalent to > "%m" and "%.6t" does what David wants, and we won't have to > search for a new escape letter when the day arrives that > somebody wants nanosecond resolution. The same could be done > with %n, avoiding the need to find a different escape letter > for that. I'll build this more sprintf-like thing if not doing so prevents the change from happening, but frankly, I don't really see a point in it because the next "log timestamps at some random negative power of 10 second granularity" requirement I see will be the first. Best, David. -- David Fetter http://fetter.org/ Phone: +1 415 235 3778 Remember to vote! Consider donating to Postgres: http://www.postgresql.org/about/donate