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 1tn9JW-002bfe-4K for pgsql-hackers@arkaria.postgresql.org; Wed, 26 Feb 2025 04:46:30 +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 1tn9JU-00F1z3-G7 for pgsql-hackers@arkaria.postgresql.org; Wed, 26 Feb 2025 04:46:28 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tn9JU-00F1yv-6B for pgsql-hackers@lists.postgresql.org; Wed, 26 Feb 2025 04:46:28 +0000 Received: from oss.nttdata.com ([49.212.34.109]) by makus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tn9JQ-0007vH-0e for pgsql-hackers@postgresql.org; Wed, 26 Feb 2025 04:46:27 +0000 Received: from [192.168.179.9] (mo110-161-173-166.air.mopera.net [110.161.173.166]) by oss.nttdata.com (Postfix) with ESMTPSA id D1B1961B74; Wed, 26 Feb 2025 13:46:20 +0900 (JST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at oss.nttdata.com Message-ID: <65fe2d68-a214-40f0-80a8-56ca7323ad5c@oss.nttdata.com> Date: Wed, 26 Feb 2025 13:46:19 +0900 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Log connection establishment timings To: Melanie Plageman , Bertrand Drouvot Cc: Guillaume Lelarge , Pg Hackers , Daniel Gustafsson , andrey.chudnovskiy@microsoft.com, Jelte Fennema-Nio , Jacob Champion References: Content-Language: en-US From: Fujii Masao In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2025/02/26 6:36, Melanie Plageman wrote: > On Tue, Feb 25, 2025 at 3:23 PM Melanie Plageman > wrote: >> >> Thanks for doing this! I have implemented your suggestion in attached v3. > > I missed an include in the EXEC_BACKEND not defined case. attached v4 > is fixed up. Thanks for updating the patch! + /* Capture time Postmaster initiates fork for logging */ + if (child_type == B_BACKEND) + INSTR_TIME_SET_CURRENT(((BackendStartupData *) startup_data)->fork_time); When log_connections is enabled, walsender connections are also logged. However, with the patch, it seems the connection time for walsenders isn't captured. Is this intentional? With the current patch, when log_connections is enabled, the connection time is always captured, and which might introduce performance overhead. No? Some users who enable log_connections may not want this extra detail and want to avoid such overhead. So, would it make sense to extend log_connections with a new option like "timing" and log the connection time only when "timing" is specified? + ereport(LOG, + errmsg("backend ready for query. pid=%d. socket=%d. connection establishment times (ms): total: %ld, fork: %ld, authentication: %ld", + MyProcPid, + (int) MyClientSocket->sock, Why expose the socket's file descriptor? I'm not sure how users would use that information. Including the PID seems unnecessary since it's already available via log_line_prefix with %p? Regards, -- Fujii Masao Advanced Computing Technology Center Research and Development Headquarters NTT DATA CORPORATION