Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1syC0c-00F05h-HG for pgsql-hackers@arkaria.postgresql.org; Tue, 08 Oct 2024 15:20:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1syC0b-009bwq-8O for pgsql-hackers@arkaria.postgresql.org; Tue, 08 Oct 2024 15:20:21 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1syC0a-009bwD-Qh for pgsql-hackers@lists.postgresql.org; Tue, 08 Oct 2024 15:20:20 +0000 Received: from mail.postgrespro.ru ([93.174.131.139]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1syC0X-0000eR-Lr for pgsql-hackers@lists.postgresql.org; Tue, 08 Oct 2024 15:20:20 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mx2023; t=1728400818; bh=LpFp/ltGwMOSspouJeNLpiQlR1Bk2kRiGoSZe3kv6wo=; h=Message-ID:Date:User-Agent:Subject:To:Cc:References:From: In-Reply-To:From; b=NVVN8B/PQpaaKuw6jaqo9gNkekRvjlaGQ3QAhCykA/BYGal4Go1DBW7kv+raZ0Aw2 16yEvVC2TgYi6d+W671eqt0s52du+LxG4lvdGtqhSD9BToCzQXqQq0TAKtISImcQ1M PpVAIM+luJOuoZVyRytJAt2XwdHX+pMEqricgJzac7tNDWUj9SF7ECw5GMgvIo4jSo UYOLfx/hxPCfAqieliiIDdqJ02tZAetwUnTumZ36rgQ+7sTrzDdhhSmpo284liutRy GCDUNZ9Hy66/m8RuoWoZnh4bu9YgiWb4oWT3oj7V9FHrJIdac3kf3gz6EbxKDPbbEd M9/jBeZBKE6UA== Received: from [172.30.33.154] (unknown [172.30.33.154]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: a.rybakina@postgrespro.ru) by mail.postgrespro.ru (Postfix/587) with ESMTPSA id E716E606DF; Tue, 8 Oct 2024 18:20:17 +0300 (MSK) Message-ID: <27273ef8-e211-4ad9-ba55-d3947bd179b8@postgrespro.ru> Date: Tue, 8 Oct 2024 18:20:17 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Add parallel columns for seq scan and index scan on pg_stat_all_tables and _indexes To: Michael Paquier Cc: Guillaume Lelarge , Bertrand Drouvot , PostgreSQL Hackers References: <09424f5e-4ddf-4830-a21f-161e0427f112@postgrespro.ru> Content-Language: en-US From: Alena Rybakina In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-KSMG-AntiPhishing: NotDetected X-KSMG-AntiSpam-Interceptor-Info: not scanned X-KSMG-AntiSpam-Status: not scanned, disabled by settings X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 2.1.0.7854, bases: 2024/10/08 08:46:00 #26716404 X-KSMG-AntiVirus-Status: NotDetected, skipped X-KSMG-LinksScanning: not scanned, disabled by settings X-KSMG-Message-Action: skipped X-KSMG-Rule-ID: 1 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 07.10.2024 03:41, Michael Paquier wrote: > On Mon, Oct 07, 2024 at 12:43:18AM +0300, Alena Rybakina wrote: >> Maybe I'm not aware of the whole context of the thread and maybe my >> questions will seem a bit stupid, but honestly >> it's not entirely clear to me how this statistics will help to adjust the >> number of parallel workers. >> We may have situations when during overestimation of the cardinality during >> query optimization a several number of parallel workers were unjustifiably >> generated and vice versa - >> due to a high workload only a few number of workers were generated. >> How do we identify such cases so as not to increase or decrease the number >> of parallel workers when it is not necessary? > Well. For spiky workloads, only these numbers are not going to help. > If you can map them with the number of times a query related to these > tables has been called, something that pg_stat_statements would be > able to show more information about. > > FWIW, I have doubts that these numbers attached to this portion of the > system are always useful. For OLTP workloads, parallel workers would > unlikely be spawned because even with JOINs we won't work with a high > number of tuples that require them. This could be interested with > analytics, however complex query sequences mean that we'd still need > to look at all the plans involving the relations where there is an > unbalance of planned/spawned workers, because these can usually > involve quite a few gather nodes. At the end of the day, it seems to > me that we would still need data that involves statements to track > down specific plans that are starving. If your application does not > have that many statements, looking at individial plans is OK, but if > you have hundreds of them to dig into, this is time-consuming and > stats at table/index level don't offer data in terms of stuff that > stands out and needs adjustments. > > And this is without the argument of bloating more the stats entries > for each table, even if it matters less now that these stats are in > shmem lately. To be honest, it’s not entirely clear to me how these statistics will help in setting up parallel workers. As I understand, we need additional tools for analytics, which are available in pg_stat_statements, but how then does it work? maybe you have the opportunity to demonstrate this? -- Regards, Alena Rybakina Postgres Professional