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 1slT6s-007xV4-7t for pgsql-hackers@arkaria.postgresql.org; Tue, 03 Sep 2024 12:58:14 +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 1slT6q-00BT7S-Ot for pgsql-hackers@arkaria.postgresql.org; Tue, 03 Sep 2024 12:58:12 +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 1slT6q-00BT7K-FB for pgsql-hackers@lists.postgresql.org; Tue, 03 Sep 2024 12:58:12 +0000 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1slT6n-000S2y-RC for pgsql-hackers@lists.postgresql.org; Tue, 03 Sep 2024 12:58:11 +0000 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-374c3400367so2018059f8f.2 for ; Tue, 03 Sep 2024 05:58:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725368288; x=1725973088; darn=lists.postgresql.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=5wMDky3U2fBTWc2qL33D3ufhiPQSXC/9RggRB17DJf0=; b=DzOcgYOer9N+vx0+aSWNJOdY4+3x278sNI+J/9pqB2AhwnAPB+dBehVZElrUvRyjIy SJOTMuzEbpLc/FVMKtFkQWHlnDqlLqxUaUVGRPtbjRoI7QmggdJ/MP58ri82QfAOdGFW zKoBsiHHxHNAI1RCEVkbxUlAwYJpQtCLDNC5tK0vbCrc/tFoN6kSLCOfNRYRN8OHz+Yk OVaN687gwSixlEGcEqpucvTzfL2TlQq+XJJTHSwIQwu8w529roCivKUvD2pF3svNQ6yC GJ4VnzGaASwj7p6Qm67p1HMsKtrSDIpVWExNDQmhM/fNsXNlNyP4MIoy+++ySwAGQH/V m8qA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725368288; x=1725973088; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=5wMDky3U2fBTWc2qL33D3ufhiPQSXC/9RggRB17DJf0=; b=bWwOcmSCMS7wQV4pJ9B1T++tS1KovorOCsZb1+1lDB+hjQTPRxr36lRMxF+SVRFRIL +XsMBY4Gjg4mEsSrKFw5CtZHLVCbc0NIzDE8uDDTWnjXyGWwe2UBWRaLj8I7kmkEgM/0 9bzUtipm3scq4i+zzy/9JXS1goNGTV5ZX27fVnn22+lbGnkmr+gl93FvcT2WNfjsh0Wu n1ZT1UxAZPK81rFQVmyDHGG8v3kZfu2s5zjhe+5CCLGLEjNbgZz5pKIe+zLJB5qt/ih2 FoJ6BAAYAfH8G/91GZR9tfNTdP7onUUJf12wsmCPThYbGrAVvJG4c56YeEbaouQCTb09 3YWQ== X-Forwarded-Encrypted: i=1; AJvYcCXYwlxiHOYaLDCAOWIHbYRDF+8sWvg22udFn2+l5P6t/AJiFzP6nVMSTT5w5M6XGo1ShNbkdE/yoOpDIoCy@lists.postgresql.org X-Gm-Message-State: AOJu0Yw1Rrw7znHZLdiK46HrTTeYL5J9NBa8ZU6zB+AWfC/qbMCsmIDf NgKGdynGPLOw9p/KVVIkd9rA2cg2og07xS90t8PWO2h6WGjPRk0R X-Google-Smtp-Source: AGHT+IFc3WEmx5UTfMAaF5VgWd8hSBsWGBkSaR3MWGn58EUrpKceip1dhg/qvSfqBmL7eSm357LjiA== X-Received: by 2002:a5d:42cc:0:b0:374:c5b4:1be0 with SMTP id ffacd0b85a97d-374c5b420a1mr6108255f8f.53.1725368287639; Tue, 03 Sep 2024 05:58:07 -0700 (PDT) Received: from ?IPV6:2a0c:5a81:4405:1600:35bd:635f:fa37:21e5? ([2a0c:5a81:4405:1600:35bd:635f:fa37:21e5]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-374c96a88ebsm6263831f8f.108.2024.09.03.05.58.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 03 Sep 2024 05:58:07 -0700 (PDT) Message-ID: Date: Tue, 3 Sep 2024 14:58:05 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: using extended statistics to improve join estimates To: Tomas Vondra , Andrei Lepikhov , Andy Fan Cc: 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> <87a5khi8as.fsf@163.com> <5c9a1eee-c8ac-408b-95c4-ff388e5e12f0@postgrespro.ru> Content-Language: en-US From: Andrei Lepikhov In-Reply-To: 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 17/6/2024 18:10, Tomas Vondra wrote: > Let me quickly go through the original parts - most of this is already > in the "review" patches, but it's better to quote the main points here > to start a discussion. I'll omit some of the smaller suggestions, so > please look at the 'review' patches. > > > v20240617-0001-Estimate-joins-using-extended-statistics.patch > > - rewords a couple comments, particularly for statext_find_matching_mcv > > - a couple XXX comments about possibly stale/inaccurate comments > v20240617-0054-clauselist_selectivity_hook.patch > > - I believe this does not work with the earlier patch that removed > estimatedclaused bitmap from the "try" function. This patch set is too big to eat at once - it's just challenging to invent examples and counterexamples. Can we see these two patches in the master and analyse further improvements based on that? Some thoughts: You remove verRelid. I have thought about replacing this value with RelOptInfo, which would allow extensions (remember selectivity hook) to know about the underlying path tree. The first patch is generally ok, and I vote for having it in the master. However, the most harmful case I see most reports about is parameterised JOIN on multiple anded clauses. In that case, we have a scan filter on something like the below: x = $1 AND y = $2 AND ... As I see, current patch doesn't resolve this issue currently. -- regards, Andrei Lepikhov