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 1s9xyg-006dUk-U8 for pgsql-hackers@arkaria.postgresql.org; Thu, 23 May 2024 02:14:48 +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 1s9xyg-006avV-At for pgsql-hackers@arkaria.postgresql.org; Thu, 23 May 2024 02:14:46 +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 1s9xyf-006avM-TB for pgsql-hackers@lists.postgresql.org; Thu, 23 May 2024 02:14:45 +0000 Received: from m16.mail.163.com ([117.135.210.4]) by makus.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1s9xyX-001Xwy-R3 for pgsql-hackers@lists.postgresql.org; Thu, 23 May 2024 02:14:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-ID:MIME-Version: Content-Type; bh=QhnnJKxfePFODeDcw1Wdma6EoLCPmA1pITXa7p/gYFE=; b=cYc5WoUEnre6tWW4jQY+vzLk0quCMOKkgrrP2IlRqrSYMGqjzBlRwtG5wX23JM utV7GFjZukfykOij4ueh7Y6Bj16/jXk0sw3ikiG2CtItpUK31au4oSxnX1ZkAZyR KksoHfHxRE5V6Agiw9yJmYPd/W2bpcIxasf9hZkF6znwE= Received: from 8235eee8a2a0 (unknown [140.205.118.211]) by gzga-smtp-mta-g3-5 (Coremail) with SMTP id _____wD3_7d7pk5mtHtXFg--.14123S3; Thu, 23 May 2024 10:14:20 +0800 (CST) 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> User-agent: mu4e 1.10.7; emacs 29.1 From: Andy Fan To: Andrei Lepikhov Cc: Tomas Vondra , Julien Rouhaud , Andres Freund , pgsql-hackers@postgresql.org, Justin Pryzby , pgsql-hackers@lists.postgresql.org Subject: Re: using extended statistics to improve join estimates Date: Thu, 23 May 2024 10:04:27 +0800 In-reply-to: Message-ID: <87a5khi8as.fsf@163.com> MIME-Version: 1.0 Content-Type: text/plain X-CM-TRANSID:_____wD3_7d7pk5mtHtXFg--.14123S3 X-Coremail-Antispam: 1Uf129KBjvJXoW7WFWkuFW3ZF47tFW3ZrWrZrb_yoW8ZF17pF ZxtayfArWDtFWIqr1fCFnrXrn29w18JryfJw1fWw1UAryUCr4Syr1xKa1YvFW2kr1ru3y2 vryUKa93Zr4Fy3DanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07UTCJQUUUUU= X-Originating-IP: [140.205.118.211] X-CM-SenderInfo: x2klx3xlid0iqsrtqiywtou0bp/1tbiNgDnU2XAllMVDwAAs4 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Andrei Lepikhov writes: > 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. OK, I didn't pay enough attention to this comment before. and yes, I get the same conclusion as you - there is no implementation of this. and if so, I think we should remove the comments and do the implementation in the next patch. >>> 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. OK. Do you think the hook proposal is closely connected with the current topic? IIUC it's seems not. So a dedicated thread to explain the problem to slove and the proposal and the follwing discussion should be helpful for both topics. I'm just worried about mixing the two in one thread would make things complexer unnecessarily. -- Best Regards Andy Fan