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 1nJYVE-0002uq-RW for pgsql-hackers@arkaria.postgresql.org; Mon, 14 Feb 2022 10:22:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nJYVC-00086H-DI for pgsql-hackers@arkaria.postgresql.org; Mon, 14 Feb 2022 10:22:38 +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 1nJYVC-000868-3M for pgsql-hackers@lists.postgresql.org; Mon, 14 Feb 2022 10:22:38 +0000 Received: from mail.postgrespro.ru ([93.174.131.139]) by makus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nJYV8-0003xc-Rq for pgsql-hackers@lists.postgresql.org; Mon, 14 Feb 2022 10:22:37 +0000 Received: from [192.168.28.53] (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 DB09421C0B84; Mon, 14 Feb 2022 13:22:31 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1644834152; bh=4GeUkWZQ+oxGgX43lr1J5rTmC69DJJZLLvVd9lTX5sc=; h=Date:From:Subject:To:Cc:References:In-Reply-To; b=oygo2adHTneS5WZo97Xo6nCWtNkv2olzVzpddzkX9Jo2/vlnwAe1886HxTrCAYW3e vkUoPxpPJnVbc/zZxa9Fuacss8DcVzYaD8a23HmFqZqzuZ+199110Hz5DJmtvqbTH4 w8yEMP/vZPYihPK7lBwaEjwH+P9WxcZ1rtPN32Nk= Message-ID: Date: Mon, 14 Feb 2022 15:22:30 +0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.6.0 From: "Andrey V. Lepikhov" Subject: Re: Merging statistics from children instead of re-sampling everything To: Tomas Vondra , PostgreSQL Hackers Cc: d.belyalov@postgrespro.ru References: <078c36f0-fc9c-b2d9-2bae-8eebafcefe93@enterprisedb.com> <92ce5a13-f97f-b4e8-c0f7-01c53d917f4f@postgrespro.ru> <82fcba0a-7c50-c714-2a6b-f2677affe65d@postgrespro.ru> <949f204b-44e2-4e41-67ff-f93643828f4a@enterprisedb.com> <4e86ae74-4e2c-b40f-4405-035d2f818e5d@enterprisedb.com> <90e400a2-9afa-15c6-8c3c-bac9f68cb9f3@postgrespro.ru> <901c13d7-b37f-3a2d-062a-3696d58d030c@enterprisedb.com> Content-Language: en-US Organization: Postgres Professional In-Reply-To: <901c13d7-b37f-3a2d-062a-3696d58d030c@enterprisedb.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2/11/22 20:12, Tomas Vondra wrote: > > > On 2/11/22 05:29, Andrey V. Lepikhov wrote: >> On 2/11/22 03:37, Tomas Vondra wrote: >>> That being said, this thread was not really about foreign partitions, >>> but about re-analyzing inheritance trees in general. And sampling >>> foreign partitions doesn't really solve that - we'll still do the >>> sampling over and over. >> IMO, to solve the problem we should do two things: >> 1. Avoid repeatable partition scans in the case inheritance tree. >> 2. Avoid to re-analyze everything in the case of active changes in >> small subset of partitions. >> >> For (1) i can imagine a solution like multiplexing: on the stage of >> defining which relations to scan, group them and prepare parameters of >> scanning to make multiple samples in one shot. > I'm not sure I understand what you mean by multiplexing. The term > usually means "sending multiple signals at once" but I'm not sure how > that applies to this issue. Can you elaborate? I suppose to make a set of samples in one scan: one sample for plane table, another - for a parent and so on, according to the inheritance tree. And cache these samples in memory. We can calculate all parameters of reservoir method to do it. > sample might be used for estimation of clauses directly. You mean, to use them in difficult cases, such of estimation of grouping over APPEND ? > > But it requires storing the sample somewhere, and I haven't found a good > and simple way to do that. We could serialize that into bytea, or we > could create a new fork, or something, but what should that do with > oversized attributes (how would TOAST work for a fork) and/or large > samples (which might not fit into 1GB bytea)? This feature looks like meta-info over a database. It can be stored in separate relation. It is not obvious that we need to use it for each relation, for example, with large samples. I think, it can be controlled by a table parameter. -- regards, Andrey Lepikhov Postgres Professional