Re: LibPQ: PQresultMemorySize as proxy to transfered bytes

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
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-11-22 16:16:37
Message-ID: 202311221616.bkvtixw2nw3n@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 2023-Jun-28, Dominique Devienne wrote:

> And if there's a better proxy to programmatically know the network
> traffic exchanged on the connection's socket, that's cross-platform?
> Obviously
> libpq itself knows, but I don't see any way to access that info.
>
> Perhaps tracing might? But will that incur overhead?

Maybe you can use PQtrace()[1], yeah. It will indicate, for each message
transmitted, its size in bytes. Naturally there will be some overhead
in writing the trace file. Also, the format of the output file has some
issues[2] that may make it difficult to machine-parse. But it might be
good enough for you ... or you might find yourself motivated to fix
these problems.

[1] https://www.postgresql.org/docs/current/libpq-control.html#LIBPQ-PQTRACE
[2] https://www.postgr.es/m/CAFCRh-8OPoe%3D0j9v4wth7qU-x4jvjVc8DoOLV66qdnC9Do0ymw%40mail.gmail.com

--
Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/
"Doing what he did amounts to sticking his fingers under the hood of the
implementation; if he gets his fingers burnt, it's his problem." (Tom Lane)

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Erik Wienhold 2023-11-22 16:18:12 Re: Feature request: pg_get_tabledef(text)
Previous Message Ron Johnson 2023-11-22 16:13:23 Configuration knobs & dials to speed up query optimization