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-02 19:20:01
Message-ID: bc017bd0-c00c-44a8-0a81-69319135446d@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 02.11.2020 19:53, Matthias van de Meent wrote:
> This is the result of network traffic of two backends one with enabled
>> compression and another with disable compression
>> after execution of "select * from pg_class" command:
>>
>> select * from pg_stat_network_traffic;
>> pid | rx_raw_bytes | tx_raw_bytes | rx_compressed_bytes |
>> tx_compressed_bytes
>> -------+--------------+--------------+---------------------+---------------------
>> 22276 | 29 | 86327 | 38
>> | 10656
>> 22282 | 73 | 86327 | 0
>> | 0
> The current names and values of these columns are confusing me:
> What column contains the amount of bytes sent to/received from the
> client? Is the compression method of pid 22282 extremely efficient at
> compressing, or does it void the data (compresses down to 0 bytes)?
Names of the columns can be changed if you or somebody else will propose
better alternatives.
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.

> I suggest having columns that contain the bytes sent to/received
> from the client before and after compression. If no compression was
> used, those numbers are expected to be equal. Example names are
> `rx_raw_bytes` and `rx_data_bytes`, `rx_received_bytes` and
> `rx_bytes_uncompressed`. Another option would be initializing /
> setting rx_compressed_bytes and tx_compressed_bytes to -1 or NULL for
> connections that do not utilize compression, to flag that
> compression is not used.
>
>
> -Matthias

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2020-11-02 19:34:57 Re: Online checksums verification in the backend
Previous Message John Naylor 2020-11-02 19:08:57 Re: [proposal] de-TOAST'ing using a iterator