Re: LibPQ: PQresultMemorySize as proxy to transfered bytes

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Dominique Devienne <ddevienne(at)gmail(dot)com>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: LibPQ: PQresultMemorySize as proxy to transfered bytes
Date: 2023-06-28 11:16:27
Message-ID: 1140652.1687950987@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Dominique Devienne <ddevienne(at)gmail(dot)com> 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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Rita 2023-06-28 11:19:23 pgbouncer
Previous Message Laurenz Albe 2023-06-28 10:43:00 Re: Replication between different 15.x minor versions ok?