Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kZfNh-00018x-Ti for pgsql-hackers@arkaria.postgresql.org; Mon, 02 Nov 2020 19:20:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kZfNB-0007az-Eo for pgsql-hackers@arkaria.postgresql.org; Mon, 02 Nov 2020 19:20:09 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kZfNB-0007as-6W for pgsql-hackers@lists.postgresql.org; Mon, 02 Nov 2020 19:20:09 +0000 Received: from mail.postgrespro.ru ([93.174.131.139]) by makus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kZfN8-0006gc-26 for pgsql-hackers@lists.postgresql.org; Mon, 02 Nov 2020 19:20:08 +0000 Received: from [192.168.28.74] (cyclops.postgrespro.ru [93.174.131.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mail.postgrespro.ru (Postfix) with ESMTPSA id 29E3221C0239; Mon, 2 Nov 2020 22:20:02 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1604344802; bh=GLW/4DVqz6V7BjzjPBLzhr33vfo9gJzpN/ov7YlU4lg=; h=Subject:To:Cc:References:From:Date:In-Reply-To; b=LUIbDCilLv/mJyu/fOubK4YOd9ipmuKFSbKs3lCLwStxZPAsMwO8RZo4hmf5zRiC5 AQ8jxAVGOsDYIcxYcilJ2TrtAzwjbYC7Wpe49ozkF+gNLBtBBjKFLZ/qmVdsLYHE+v DBJuH/feX6jUwzj8zfq1+fFajYaZ++AETihhtyRU= Subject: Re: libpq compression To: Matthias van de Meent Cc: Daniil Zakhlystov , Andres Freund , PostgreSQL Hackers , "Andrey M. Borodin" , "o.bartunov@postgrespro.ru" References: <74F0A385-6ED4-4EA7-9498-1A8527F16472@yandex-team.ru> <22446ba0-058d-624a-a679-edc0215a56c8@postgrespro.ru> <20201028192712.xj2qneyb3fvmjm6c@alap3.anarazel.de> <3b1d2752-b7b5-db39-84c9-4ff024041fff@postgrespro.ru> <20201030210308.54jjmnvhspk6p7cb@alap3.anarazel.de> <0ae2162b-818f-6a6d-cca6-ee4e73733e8e@postgrespro.ru> <67498D86-006D-4D56-85E2-88ABA07B2715@yandex-team.ru> <34328cc0-9669-f30d-50f6-46e9f3f21cde@postgrespro.ru> <9d33e21e-54b2-fcf3-b90f-ced286df00c5@postgrespro.ru> From: Konstantin Knizhnik Message-ID: Date: Mon, 2 Nov 2020 22:20:01 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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