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 1rrimp-002Hec-2P for pgsql-hackers@arkaria.postgresql.org; Tue, 02 Apr 2024 18:23:07 +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 1rrimn-00Aibo-Q2 for pgsql-hackers@arkaria.postgresql.org; Tue, 02 Apr 2024 18:23:05 +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 1rrimn-00Aibf-Fm for pgsql-hackers@lists.postgresql.org; Tue, 02 Apr 2024 18:23:05 +0000 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rrimh-000GuH-6U for pgsql-hackers@lists.postgresql.org; Tue, 02 Apr 2024 18:23:03 +0000 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-4162060dc6eso869975e9.1 for ; Tue, 02 Apr 2024 11:22:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; t=1712082177; x=1712686977; 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=MXPTa0DQeNq8b4B/+YkAWdz36G2YO6kt65YyPgg0ZRQ=; b=kEuukvDdvj7tEqenWYCqNYu5/14nzTRuh8TYdN3OVCYx5pzvAs/ZCnkrGT8FC5B5fF OlLmS0BaqRrHpDEeATMaOdjTNGQ7cArfGN8wWbGql2UBqPjZRFz5iczgdej/vn4b6hng r+y336oPIBlKF0LpIxlZC11rXc0Fe0Wo9xKRdZAiQXVtK4pCq7a/yjNQQGOGqt3bT/Za XoAbe0PftPbl7rho4Ecfmqq09tJCsgJtcj6SUvgU28z0kQrwVGtZbKrkWQh/xTUmg0GJ zYDef9cieGoAEXCjM3RpThw1h+x/xo1z0P6QCuzbOrIZJ0MYEAmgSVuZJKgrK7iJHWP3 85Iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712082177; x=1712686977; 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=MXPTa0DQeNq8b4B/+YkAWdz36G2YO6kt65YyPgg0ZRQ=; b=O//uInpo7vFEvcOHkCtTVx6cxPfIimTxybehiYzZX4NcdXtVzaZnF3Ql/mf/MWJdTL EVs61y9ozkLYtXc2DrPpsLCLAdLC8hzo59iHpLDgX1gdzaJrrynXzYlToLg5ESjXUCvz ZeIUMIoQDJYRqMFV5sG4VmOmqZRVIoZ9qlkEb0y+PmDf7lMA/MkGyTumRcK23thMJxAv KvAG45GkmbRsMdOmUQil6tPZY6swkn8c2VAw9E0M/QeBuQk42Zgetcl0YGq3Qw1XFP0t +5XCxzab2hgQebAiRer6DESe2LyXJd1cW15WgB574Esty1sNwXezlUmrMinIoMQE0OTE 8iBA== X-Forwarded-Encrypted: i=1; AJvYcCUMH7ATOn0XwivsWH0XbCPexqYJtnSkt78TXBtfiUA9vZr9uqVVI+EIuX6fY0oyVPrxLfuuolm3GEFJFpxsr1qIRar4hVl0Z8EqQy7Y06jgPTSQ X-Gm-Message-State: AOJu0Yxy6hrlU9zYIW9nU++r6S8vKNcIkxO67ULGR20KJ+z55dK/yz3T Ix+BNm1MVwCUudgkmB8rKqU+eYDCSw2no5GSa9Dm4WJNNIxPr8hWQV3otLzRYg== X-Google-Smtp-Source: AGHT+IFI22tSyxAJOA82oGYheLBdouUnKNRVcrZAwS3AXNZeaTVeKu3idHtUV00dHX613Sie1J3VMA== X-Received: by 2002:a05:600c:4447:b0:415:6e01:27a8 with SMTP id v7-20020a05600c444700b004156e0127a8mr238483wmn.14.1712082176790; Tue, 02 Apr 2024 11:22:56 -0700 (PDT) Received: from [10.137.0.18] (ip-86-49-229-30.bb.vodafone.cz. [86.49.229.30]) by smtp.gmail.com with ESMTPSA id n17-20020a05600c3b9100b0041493aae77esm22063279wms.23.2024.04.02.11.22.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 02 Apr 2024 11:22:56 -0700 (PDT) Message-ID: <2a9604a5-520d-48ee-b3c8-5f3342b607d3@enterprisedb.com> Date: Tue, 2 Apr 2024 20:22:55 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: using extended statistics to improve join estimates To: Andy Fan , Justin Pryzby Cc: Julien Rouhaud , Andres Freund , pgsql-hackers@postgresql.org, 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> Content-Language: en-US From: Tomas Vondra In-Reply-To: <87cyr89nk5.fsf@163.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 4/2/24 10:23, Andy Fan wrote: > >> On Wed, Mar 02, 2022 at 11:38:21AM -0600, Justin Pryzby wrote: >>> Rebased over 269b532ae and muted compiler warnings. > > Thank you Justin for the rebase! > > Hello Tomas, > > Thanks for the patch! Before I review the path at the code level, I want > to explain my understanding about this patch first. > If you want to work on this patch, that'd be cool. A review would be great, but if you want to maybe take over and try moving it forward, that'd be even better. I don't know when I'll have time to work on it again, but I'd promise to help you with working on it. > Before this patch, we already use MCV information for the eqjoinsel, it > works as combine the MCV on the both sides to figure out the mcv_freq > and then treat the rest equally, but this doesn't work for MCV in > extended statistics, this patch fill this gap. Besides that, since > extended statistics means more than 1 columns are involved, if 1+ > columns are Const based on RestrictInfo, we can use such information to > filter the MCVs we are interesting, that's really cool. > Yes, I think that's an accurate description of what the patch does. > I did some more testing, all of them are inner join so far, all of them > works amazing and I am suprised this patch didn't draw enough > attention. I will test more after I go though the code. > I think it didn't go forward for a bunch of reasons: 1) I got distracted by something else requiring immediate attention, and forgot about this patch. 2) I got stuck on some detail of the patch, unsure which of the possible solutions to try first. 3) Uncertainty about how applicable the patch is in practice. I suppose it was some combination of these reasons, not sure. As for the "practicality" mentioned in (3), it's been a while since I worked on the patch so I don't recall the details, but I think I've been thinking mostly about "start join" queries, where a big "fact" table joins to small dimensions. And in that case the fact table may have a MCV, but the dimensions certainly don't have any (because the join happens on a PK). But maybe that's a wrong way to think about it - it was clearly useful to consider the case with (per-attribute) MCVs on both sides as worth special handling. So why not to do that for multi-column MCVs, right? > At for the code level, I reviewed them in the top-down manner and almost > 40% completed. Here are some findings just FYI. For efficiency purpose, > I provide each feedback with a individual commit, after all I want to > make sure my comment is practical and coding and testing is a good way > to archive that. I tried to make each of them as small as possible so > that you can reject or accept them convinently. > > 0001 is your patch, I just rebase them against the current master. 0006 > is not much relevant with current patch, and I think it can be committed > individually if you are OK with that. > > Hope this kind of review is helpful. > 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. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company