Re: libpq compression - Mailing list pgsql-hackers

From Konstantin Knizhnik
Subject Re: libpq compression
Date
Msg-id a604ecba-86a0-d9e8-4fab-6cb4fa77cbc1@postgrespro.ru
Whole thread Raw
In response to Re: libpq compression  (Matthias van de Meent <boekewurm+postgres@gmail.com>)
Responses Re: libpq compression  (Matthias van de Meent <boekewurm+postgres@gmail.com>)
List pgsql-hackers


On 05.11.2020 15:40, Matthias van de Meent wrote:

How about Xx_logical_bytes for raw the pg command stream data, and
keeping Xx_compressed_bytes for the compressed data in/out?

Frankly speaking I do not like work "logical" in this context.
It is in any case physical bytes, received from the peer.
Speaking about compression or encryption, "raw" is much widely used
for uncompressed or plain data.

This view pg_stat_network_traffic reports traffic from server (backend)
point of view, i.e.
rx_bytes (received bytes) are commands sent from client to the server
tx_bytes (transmitted bytes) are responses sent by server to the client.

If compression is not used then rx_compressed_bytes =
tx_compressed_bytes = 0
It seems to be more natural then assigning them the same values as (raw
bytes).
Because it can really happen that for BLOBs with already compressed data
(video images or sound)
compressed data will be almost the same as raw data even if compression
is enabled.
So it seems to be important to distinguished situations when data can
not be compressed and
when it is not compressed at all.
Looking at it from that viewpoint, I agree. My primary reason for
suggesting this was that it would be useful to expose how much data
was transferred between the client and the server, which cannot be
constructed from that view for compression-enabled connections. That
is because the compression methods' counting only starts after some
bytes have already been transferred, and the raw/logical counter
starts deviating once compression is enabled.

Sorry, I do not understand your point.
This view reports network traffic from server's side.
But client's traffic information is "mirror" of this statistic: server_tx=client_rx and visa versa.

Yes, first few bytes exchanged by client and server during handshake are not compressed.
But them are correctly calculated as "raw bytes". And certainly this few bytes can not have any influence on
measured average compression ratio (the main goal of using this network traffic statistic from my point of view).



-- 
Konstantin Knizhnik
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company 

pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: redundant error messages
Next
From: Fujii Masao
Date:
Subject: REFRESH MATERIALIZED VIEW and completion tag output