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 1s8zVr-00Gaa4-7S for pgsql-hackers@arkaria.postgresql.org; Mon, 20 May 2024 09:41:01 +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 1s8zVq-000D1n-Lp for pgsql-hackers@arkaria.postgresql.org; Mon, 20 May 2024 09:40:58 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s8zVq-000D1T-35 for pgsql-hackers@lists.postgresql.org; Mon, 20 May 2024 09:40:58 +0000 Received: from mail.postgrespro.ru ([93.174.131.139]) by makus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s8zVm-0016HX-Db for pgsql-hackers@postgresql.org; Mon, 20 May 2024 09:40:56 +0000 Received: from [172.30.8.38] (unknown [172.30.8.38]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: a.lepikhov@postgrespro.ru) by mail.postgrespro.ru (Postfix/587) with ESMTPSA id 506E2E20EEE; Mon, 20 May 2024 12:40:42 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mx2023; t=1716198050; bh=X1DsGnFI9SP8kyEPveJDCryGHOgque5k8ysP0hr05Vc=; h=Message-ID:Date:User-Agent:Subject:To:Cc:References:From: In-Reply-To:From; b=5KHlyB8v0ya/f1V6mhfBBatWd9/Zvm8Jxou17RqptRezZmFzzdQKZ1q7Kk4L1rTdJ kQIV6ajX7J8VEm1L404qYYF+mPG4Z+gTH6z4GVin5UH4O3vrEqXQptIqNoeK2zHuSG 1wowHaIsTt1YKdN3u+qQPcTFvgxWW2cOyFChlAkk/LDJiGZn4Xo6SyrfjafPNhjDqP ndOPzkevEerDLrCnFkrsJCm4o7uBO/CLutc1BLLJFyxLTlGr2KTKGRw30ouKqoC+gd tp6UwNltL6hv9o5s/YH3IdEkiyyNQYiDSqu92LMgktc0cqacMqY4VHT6kod90gdhel PFFjOE+RTsGpg== Message-ID: Date: Mon, 20 May 2024 16:40:31 +0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: using extended statistics to improve join estimates To: Andy Fan Cc: Tomas Vondra , Julien Rouhaud , Andres Freund , pgsql-hackers@postgresql.org, Justin Pryzby , pgsql-hackers@lists.postgresql.org References: <2ed75657-e084-9539-c6de-597e5675014c@enterprisedb.com> <20211122012315.GH17618@telsasoft.com> <0213d237-efd5-8e7e-fa29-3f36e6e26023@enterprisedb.com> <1ea3bf2b-57f9-e632-251a-e718623d7a72@enterprisedb.com> <20220104235550.dgr4rz6zkjx2rykz@alap3.anarazel.de> <20220119101809.wzrjvh4jsnoakgny@jrouhaud> <20220302173821.GG15744@telsasoft.com> <20220302173943.GA28810@telsasoft.com> <87cyr89nk5.fsf@163.com> <2a9604a5-520d-48ee-b3c8-5f3342b607d3@enterprisedb.com> <866452b8-67b3-4f67-b85c-c3bb8e831ff2@postgrespro.ru> <87o790kgj3.fsf@163.com> Content-Language: en-US From: Andrei Lepikhov Organization: Postgres Professional In-Reply-To: <87o790kgj3.fsf@163.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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/05/20 04:38:00 #25249872 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 20/5/2024 15:52, Andy Fan wrote: > > Hi Andrei, > >> On 4/3/24 01:22, Tomas Vondra wrote: >>> Cool! There's obviously no chance to get this into v18, and I have stuff >>> to do in this CF. But I'll take a look after that. >> I'm looking at your patch now - an excellent start to an eagerly awaited >> feature! >> A couple of questions: >> 1. I didn't find the implementation of strategy 'c' - estimation by the >> number of distinct values. Do you forget it? > > What do you mean the "strategy 'c'"? As described in 0001-* patch: * c) No extended stats with MCV. If there are multiple join clauses, * we can try using ndistinct coefficients and do what eqjoinsel does. > >> 2. Can we add a clauselist selectivity hook into the core (something >> similar the code in attachment)? It can allow the development and >> testing of multicolumn join estimations without patching the core. > > The idea LGTM. But do you want > > + if (clauselist_selectivity_hook) > + s1 = clauselist_selectivity_hook(root, clauses, varRelid, jointype, > + > > rather than > > + if (clauselist_selectivity_hook) > + *return* clauselist_selectivity_hook(root, clauses, ..) Of course - library may estimate not all the clauses - it is a reason, why I added input/output parameter 'estimatedclauses' by analogy with statext_clauselist_selectivity. -- regards, Andrei Lepikhov Postgres Professional