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 1u0E8B-00ElDD-Bt for pgsql-performance@arkaria.postgresql.org; Thu, 03 Apr 2025 06:32:51 +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 1u0E89-003i4o-LL for pgsql-performance@arkaria.postgresql.org; Thu, 03 Apr 2025 06:32:49 +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 1u0E89-003i4f-Ar for pgsql-performance@lists.postgresql.org; Thu, 03 Apr 2025 06:32:49 +0000 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1u0E87-002gey-1t for pgsql-performance@lists.postgresql.org; Thu, 03 Apr 2025 06:32:48 +0000 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-43cf628cb14so11325575e9.1 for ; Wed, 02 Apr 2025 23:32:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1743661966; x=1744266766; darn=lists.postgresql.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id:from :to:cc:subject:date:message-id:reply-to; bh=YQ1qliKf8SDRLxmAWVcSIz/Ek2opShcVzwRJUQxecLg=; b=cOZqPNp9MNZMX1w4CAcHqvQqcZUvbTV+DXBtb4UqchxuxFCUsx0WhrMeJmwUJgzCZc sqLAKbjImebW7Vt4F8cfsjhhB1jIEPKpgsXhy6PjAf2vTwgsNxtBtWfMxv3/VMyPfe5P zY3yVJQtzSei8MW0EMcr60TkyKq9ncb4rcYJx0v6v5SVa4SfjIinXq6nfEFgk1TDMdru 4iM7iJfSqJvg9dzZji3ZmipqT2RCoizrc2xHqPSFw5s80ys47GJQZ9QeECnAbiEhRy5m sAYipm6C6D2Gpq7WowEu7Vr/T3AljLo7/k1qhpxPFaycnx4WYqwi8Go5vX6ZEdvtbCSo R7Xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743661966; x=1744266766; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=YQ1qliKf8SDRLxmAWVcSIz/Ek2opShcVzwRJUQxecLg=; b=tWZG2LQUoY/58Y/iB3izY4GkS+jtAvGsiBMne/b/F1tB+PgFl6AP5RkF4UUunA2y4d TmdkjB4GEq1DnRaf2AOl+H2mptMDqmNDfsu/Cls4rflZDqN46PAS9UJ4bwwap3K2cVjW fp6KL9R3NhgNvScYQwnMjOCshk+AIpnshkYWeDgJpGMqoW53cdc/vS3pcrjCaq9jwrLI r2Cih1wxCj5KkbG6hF72y02wcJoc1ZUXPSkfGkOc+bgTi8u3q9G8vc6O3Yjg6I3pX/9/ 151tTD1Z6F1RiWJ6PvLVzipIpGBU5NOg7rUaWohJZUVYZTb9icqBMPB6u3hUmd3Wf5Uo jhJQ== X-Forwarded-Encrypted: i=1; AJvYcCVlpDaQdZNqUs4pTpBxQKlOJZ7K8TUzxCPWwHGwqmr9fIY1ZmQOJKIclJ2RrcDVuYJSbLcRsLX3HOw63WqqndhLYA==@lists.postgresql.org X-Gm-Message-State: AOJu0Yzshn28MTdVrJjF5JowXgnJHP+A/Rk4m+U66TXuMT0oGgS9mJ/d wgazp+J6S+uPTs6OKbx6GPtPo6yogqaqVR6OZgJTZaiKBBZiOQPPKxtjfxUNR0Y= X-Gm-Gg: ASbGncu1WE4AAm/NzC/KLt1t6XdTTkXv5VOO3OXUxLNbhQsvQMn/x5tlWwnag8Uus+b c99rF0Wt7INq7BwgstTNUb9kqrzxz8P5Idyqd6paJn83jaBGLLw+odk33UeixIJzm4tsDk0r9Mu pV8sjxIflZy3xXsYDIhxLh4IQF47QJf/c1g2vjMMDfZ+oxoGm7H3zEPP4LU7v/2ZclBPx6S2oCJ k1cfYl3VIleay/OqBd7X2WFvj6syec4cxDm7Hza/FG88afVxovGB59TntNNCIETmMnFG3tboodC Rd8PhmZoxiZxPYnhKyheJ80EkBDUcPb6CASwNqaAD+3I1CaYOxp7HrCXVS45nl8bUPr0R2zu+OK sTIhCTxtgCoIAiQ== X-Google-Smtp-Source: AGHT+IGGmixROQbEheygnulQ/+zMLU9fKe6MD9CxKNKekAlcevKtHfFbSAz1PcEDq7yWrnauyJOrOQ== X-Received: by 2002:a05:600c:138f:b0:439:4b23:9e8e with SMTP id 5b1f17b1804b1-43ebee8b09dmr15381755e9.3.1743661965817; Wed, 02 Apr 2025 23:32:45 -0700 (PDT) Received: from [192.168.0.89] (84.123.232.230.dyn.user.ono.com. [84.123.232.230]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43ec364ce6esm8511495e9.30.2025.04.02.23.32.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 02 Apr 2025 23:32:45 -0700 (PDT) Message-ID: Date: Thu, 3 Apr 2025 08:32:44 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: partition table optimizer join cost misestimation To: James Pang , pgsql-performance@lists.postgresql.org References: Content-Language: en-AU From: Andrei Lepikhov In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 4/3/25 02:46, James Pang wrote: > Andrei, >    Yes, from explain output, since optimizer already get the > merge_append cost but not take account into total cost, that make a big > difference.  I shared table DDLs and explain analyze,buffers output , I > think  the data maybe generated by other way to reproduce this issue. > sorry for not sharing the commercial production data here. I think it is almost enough to identify the issue. Let me ask you the following questions: 1. Can you provide min and max values in columns cc.sss_id and aa.mmm_id? 2. How often do you analyze your *parent* tables tablea and tablec? Remember, if you want to build statistics on a partitioned table (not a partition), you have to explicitly call ANALYZE tablea,tablec; mentioning these tables in the analyze list. 3. May you provide a dump of pg_statistic on attributes cc.sss_id and aa.mmm_id? 4. Is there a possibility of changing a single code line and rebuilding your DB instance to check a conjecture? -- regards, Andrei Lepikhov