Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t0ln6-00D7K7-Og for pgsql-general@arkaria.postgresql.org; Tue, 15 Oct 2024 17:57:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1t0ln4-009aDV-Ge for pgsql-general@arkaria.postgresql.org; Tue, 15 Oct 2024 17:57:02 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t0ln4-009aDM-5w for pgsql-general@lists.postgresql.org; Tue, 15 Oct 2024 17:57:02 +0000 Received: from smtp94.ord1d.emailsrvr.com ([184.106.54.94]) by magus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t0ln2-001Djw-4J for pgsql-general@lists.postgresql.org; Tue, 15 Oct 2024 17:57:01 +0000 X-Auth-ID: xof@thebuild.com Received: by smtp20.relay.ord1d.emailsrvr.com (Authenticated sender: xof-AT-thebuild.com) with ESMTPSA id 7A383C00B0; Tue, 15 Oct 2024 13:56:57 -0400 (EDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3776.700.51\)) Subject: Re: Advice on efficiently logging outputs to PostgreSQL From: Christophe Pettus In-Reply-To: Date: Tue, 15 Oct 2024 10:56:25 -0700 Cc: pgsql-general@lists.postgresql.org Content-Transfer-Encoding: quoted-printable Message-Id: References: To: Dominique Devienne X-Mailer: Apple Mail (2.3776.700.51) X-Classification-ID: 8f0cd268-dbdd-4a17-b865-0ef175bd62f9-1-1 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On Oct 15, 2024, at 07:17, Dominique Devienne = wrote: > Am I worrying too much? :) Probably. :-) The main things I'd worry about is: 1. What's the ratio of log lines to database updates? You want this to = be as high as usefully possible, since in effect you are doing write = amplification by writing to the logs as well as to the "real" database. 2. One of the things to watch out for if you are writing the log lines = to the database is that if you write a log line in a transaction, and = that transaction rolls back, you lose the log line. That may or may not = be what you want: if it's reporting an error (such as the reason that = the transaction rolled back), you want to preserve that data. One way = of handling this is to have the application have a separate session for = logging, although you are now doing 2x the number of connections. If the write volume is very high, you might consider using a dedicate = log-ingestion service (there are tons) rather than PostgreSQL, so that = you aren't overburdening the database with log activity.=