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 1q85M9-0007pR-MZ for pgsql-performance@arkaria.postgresql.org; Sat, 10 Jun 2023 20:38:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1q85M8-0000i5-IP for pgsql-performance@arkaria.postgresql.org; Sat, 10 Jun 2023 20:38:40 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q85M8-0000hu-6y for pgsql-performance@lists.postgresql.org; Sat, 10 Jun 2023 20:38:40 +0000 Received: from mail-ed1-x535.google.com ([2a00:1450:4864:20::535]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1q85M4-001TLI-9W for pgsql-performance@lists.postgresql.org; Sat, 10 Jun 2023 20:38:39 +0000 Received: by mail-ed1-x535.google.com with SMTP id 4fb4d7f45d1cf-51496f57e59so4185980a12.2 for ; Sat, 10 Jun 2023 13:38:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; t=1686429514; x=1689021514; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=1rTS0kNwZ/e/eVORuWpEwyHUpdaWJsii1AnZ1Y4LuKE=; b=iNywpmexjxkMOJJqAwFesf9Peh1uMxhZsylI1omdeuUuslcHGBaCLKm+LJmtE1g0Ep cSLCwDrD+URlIzvx/7Kwv02rbI3662LdNaoQfh3frO6i2FRtMMLsI9AFyh5MRpoW9g/F ozpCFTBq7KYsix5CGLbGquRkyOmuU3UENA+QgrVbs1Kp1wafzaAxHiKrKbTEl9oPrqTK kvskCOfJNPBDGa9z7trFUWfom5GScxvsKgu1GtH+bDu0MXmOaITUhV2OU9rAPDEPrDls Pg0oV+GNZUWtxINNpCSEJIz8TQkOVRhhljenATBzyC8rWkDpTCbX+XkkjDuGYW4EQ5fk C4Gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686429514; x=1689021514; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=1rTS0kNwZ/e/eVORuWpEwyHUpdaWJsii1AnZ1Y4LuKE=; b=TjNUxGqTuD/vQoyAndotqrO9wgL/v6Pyek4fbxRLueG4DajEVmaR6QS8gwarLI4WNO qeRSS82YwKH3hr6O6fkYdQH4oBi07ovJilAMKCm4LyQvWLEL/Ervu/XuEE1MUHxiTbTA baFx9N4YTuAY8pPxPHcSxeDa25haSU2EotVNWYIrL6pXfbOGnjDdC1XArCP4tgAZqXu7 SFD0dZjBBZMne/j3wi1owc7XJpp9zdkDVTWSRjmlpEQ1lcDZlJKJQGi4YatC+y3AtjNC Q2lj59Ejz0rA02m2kfU8s9nOql0Z4Duxk6Hn2b8W37Q1FWcsnwF30vvtOZzvtgcQSAx1 /FHw== X-Gm-Message-State: AC+VfDxnSRTS+yGwgeMf8pRkoxSwmKeqi1KcR2JGlAekJJ/erHE8PbW0 dQsVZz4RaVf8GiwchGNXwDeh4YGOTSQBlT4zKX8= X-Google-Smtp-Source: ACHHUZ6dUGAl1ZdN9SOXUeJUXzBo3P5NIz+MSoRJnKH/eQE3Jdk4NJ8LiYbzkgZlU/BkCPo4mEWxvw== X-Received: by 2002:a17:907:169f:b0:96f:2b3f:61 with SMTP id hc31-20020a170907169f00b0096f2b3f0061mr5932775ejc.7.1686429513811; Sat, 10 Jun 2023 13:38:33 -0700 (PDT) Received: from [10.137.0.17] (ip-86-49-228-220.bb.vodafone.cz. [86.49.228.220]) by smtp.gmail.com with ESMTPSA id w23-20020a1709064a1700b00978723f594bsm2929914eju.101.2023.06.10.13.38.33 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 10 Jun 2023 13:38:33 -0700 (PDT) Message-ID: <8f79dacb-332e-7bde-e9e9-1a2319aa51f4@enterprisedb.com> Date: Sat, 10 Jun 2023 22:38:31 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: wrong rows estimation by hash join Content-Language: en-US To: "James Pang (chaolpan)" , "pgsql-performance@lists.postgresql.org" References: From: Tomas Vondra In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 6/9/23 10:36, James Pang (chaolpan) wrote: >   How does hash join estimation rows ?   pg v14, it make wrong rows > estimation then leave nest loop lef join that make poor sql plan.  A > I doubt this is specific to hashjoins, we estimate cardinality the same way for all joins (or more precisely, we estimate it before picking the particular join method). I'm just guessing, but I'd bet the join condition is correlated with the filter on cs_contract: > ->  Index > Scan using cs_xxxx_test on cs_contract cc  (cost=0.43..167540.92 > rows=237989 width=115) > Index Cond: ((xx_to > CURRENT_DATE) AND ((status)::text = ANY > ('{Active,Inactive,Pending}'::text[]))) > If you remove that condition, does the estimate improve? regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company