Re: libpq compression

From: Konstantin Knizhnik <k(dot)knizhnik(at)postgrespro(dot)ru>
To: Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>
Cc: Daniil Zakhlystov <usernamedt(at)yandex-team(dot)ru>, Andres Freund <andres(at)anarazel(dot)de>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, "Andrey M(dot) Borodin" <x4mmm(at)yandex-team(dot)ru>, "o(dot)bartunov(at)postgrespro(dot)ru" <o(dot)bartunov(at)postgrespro(dot)ru>
Subject: Re: libpq compression
Date: 2020-11-05 16:01:43
Message-ID: a604ecba-86a0-d9e8-4fab-6cb4fa77cbc1@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Fujii Masao 2020-11-05 16:20:04 REFRESH MATERIALIZED VIEW and completion tag output
Previous Message Alvaro Herrera 2020-11-05 15:53:56 Re: redundant error messages