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 1qETA2-0005lV-0b for pgsql-general@arkaria.postgresql.org; Wed, 28 Jun 2023 11:16:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1qETA0-0002rn-5Y for pgsql-general@arkaria.postgresql.org; Wed, 28 Jun 2023 11:16:32 +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 1qET9z-0002re-QZ for pgsql-general@lists.postgresql.org; Wed, 28 Jun 2023 11:16:31 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qET9x-000uK8-Fn for pgsql-general@lists.postgresql.org; Wed, 28 Jun 2023 11:16:30 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 35SBGRuN1140653; Wed, 28 Jun 2023 07:16:27 -0400 From: Tom Lane To: Dominique Devienne cc: pgsql-general@lists.postgresql.org Subject: Re: LibPQ: PQresultMemorySize as proxy to transfered bytes In-reply-to: References: Comments: In-reply-to Dominique Devienne message dated "Wed, 28 Jun 2023 09:46:53 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1140651.1687950987.1@sss.pgh.pa.us> Date: Wed, 28 Jun 2023 07:16:27 -0400 Message-ID: <1140652.1687950987@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Dominique Devienne writes: > Obviously from these results, I now realize PQresultMemorySize() returns > something larger than what went across the network. Can someone explain > how so? That number is the total space actually requested from malloc() for the PGresult object. But we request space in blocks (typically 2KB each), so there's some overhead due to fields not exactly filling a block, unused space in the last block, etc. If you're testing with very small result sets (say a couple hundred KB) then the value could be pretty far off what went across the network. A larger result set should show less percentage error. regards, tom lane