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 1qAIDN-0002ES-W2 for pgsql-hackers@arkaria.postgresql.org; Fri, 16 Jun 2023 22:46:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1qAIDM-0007h1-Ai for pgsql-hackers@arkaria.postgresql.org; Fri, 16 Jun 2023 22:46:44 +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 1qAIDM-0007gq-1D for pgsql-hackers@lists.postgresql.org; Fri, 16 Jun 2023 22:46:44 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qAIDJ-002bfJ-Go for pgsql-hackers@postgresql.org; Fri, 16 Jun 2023 22:46:42 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 35GMkbpt2463030; Fri, 16 Jun 2023 18:46:38 -0400 From: Tom Lane To: Quan Zongliang cc: Tomas Vondra , pgsql-hackers Subject: Re: Incorrect estimation of HashJoin rows resulted from inaccurate small table statistics In-reply-to: <83d056c0-c3eb-6ef7-bf3a-7e461fcde74d@yeah.net> References: <83d056c0-c3eb-6ef7-bf3a-7e461fcde74d@yeah.net> Comments: In-reply-to Quan Zongliang message dated "Sat, 17 Jun 2023 06:32:58 +0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2463028.1686955597.1@sss.pgh.pa.us> Date: Fri, 16 Jun 2023 18:46:37 -0400 Message-ID: <2463029.1686955597@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Quan Zongliang writes: > Perhaps we should discard this (dups cnt > 1) restriction? That's not going to happen on the basis of one test case that you haven't even shown us. The implications of doing it are very unclear. In particular, I seem to recall that there are bits of logic that depend on the assumption that MCV entries always represent more than one row. The nmultiple calculation Tomas referred to may be failing because of that, but I'm worried about there being other places. Basically, you're proposing a rather fundamental change in the rules by which Postgres has gathered statistics for decades. You need to bring some pretty substantial evidence to support that. The burden of proof is on you, not on the status quo. regards, tom lane