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 1td3sy-004ath-5g for pgsql-performance@arkaria.postgresql.org; Wed, 29 Jan 2025 08:57:24 +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 1td3sx-005vTY-7R for pgsql-performance@arkaria.postgresql.org; Wed, 29 Jan 2025 08:57:23 +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 1td3sw-005vTN-UF for pgsql-performance@lists.postgresql.org; Wed, 29 Jan 2025 08:57:22 +0000 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1td3su-0025ZA-2B for pgsql-performance@lists.postgresql.org; Wed, 29 Jan 2025 08:57:21 +0000 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-216395e151bso6241125ad.0 for ; Wed, 29 Jan 2025 00:57:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738141040; x=1738745840; darn=lists.postgresql.org; h=content-transfer-encoding:in-reply-to:from:cc:content-language :references:to:subject:user-agent:mime-version:date:message-id:from :to:cc:subject:date:message-id:reply-to; bh=+qdY19ctwPrknAkt1xebxbaW3+hQGVQvzegj6sJxOPc=; b=Zng/yDwkKDk47yCikPSw0T7H9kDo9hMlT9+X0KF/O2AcpKth2yipVv5gImdLgjZv5c PtiDjBD1LQpwLltf2LsWfPumSyhzVRjXJEgloMcu+M3ejbf6ZtsCIk48l4e+91tQ5rb1 eyHDO7VqvdHg52vgF8ROfEPAUF0LpAAY2KOc++5+abDa8uO+RIuVryMlU1ASFT4ehjaJ dYMOme8jWQYLfvWjXOeTGEOSElwL/dcPy4/VpHoktsmX9xqkmwIw1gfDSiCehDFEKRgD LnmkJu5x8EWydoEfdMKi8xitLh+jwSEnlLc36yxCnjJ2Ob1yjALhOtPh6QamPi7AmKwJ LfYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738141040; x=1738745840; h=content-transfer-encoding:in-reply-to:from:cc: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=+qdY19ctwPrknAkt1xebxbaW3+hQGVQvzegj6sJxOPc=; b=Oq8X+3rQZv+KU9RdIvyMKLRzjCI6WxBx/QbWg043XLKeeme4ideX2TArdliMvG9CVG xHJAuJwEuMkI9XvhB2sj444YALi6hGVo5+YR8hgpo34ZR6ajWfLg1cOwhLItflX11QID iUd4UXJbjlB/fybleaSM3hOCYzWMgLg9p222gOGWJWiaw4DjXdJxPAp0LwDyaOo0mJN1 H4rny2ot5H0ww4AwYcM/j1cL6Khme7M+jZAeURYpU3VBUf6mjmHz2Qx6Ma7C8ozBC22i WVFUhDylFOV+sMLa6o4WwRll5yi5TBhN9nhX9eUzEZYtJZ6k2TWDGM+LEl/nKrtMRmx5 fung== X-Gm-Message-State: AOJu0YxNGhxX00XiTpjaOiwpqdYYW3HdHBDPI1ZMdPLDTQiQExHUeP1l FHkhlWFPl7B57suDn+P9oCLjqbZQI9Oql9yReQ8pAMaftgeb0urf X-Gm-Gg: ASbGncsxivdWnhkFeBrM6T+SNCsZ0XbxcCP5q0H0n6KwSLqBkNKPb86o3e8Zakne5mc fPOLj+0IJCuHchnu9ltviCBcso5E3u+tJuuGzQuBqHY61I8wbgUKJri/y13PEWzwzrB2/jp3cXn o4Z+t627NS/mRK41S12gnkh9kBvU+ANdnXikAmDIRvgpmwJZFcJjqnIFqO7/P9zzQ4CuDfD+KYi QRs1wPw8Yw7cVwotS8O3sShhzqVbqaIvFkL53+q8P5/qoy7rKuDU5FrAcoEKx59TjGzT+4ZOG8B hK14dLX8LYVvNTUxkyrA3Wmq6ov9VrcslqTfBMfoF7AgtSLJIAwf7zpUhdopZIO81g== X-Google-Smtp-Source: AGHT+IFNsP1OsPr0R+LXRXgBtpDurXhVlVhvspqmRbeg8MmcWC8M+3EiQcYY5wi5rmeCKohKSVnVAQ== X-Received: by 2002:a17:902:f651:b0:215:742e:5cff with SMTP id d9443c01a7336-21dd77dbefemr47721035ad.16.1738141039910; Wed, 29 Jan 2025 00:57:19 -0800 (PST) Received: from [10.10.20.106] (node-hh3.pool-125-27.dynamic.totinternet.net. [125.27.88.119]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21da424dabdsm94566995ad.253.2025.01.29.00.57.18 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 29 Jan 2025 00:57:19 -0800 (PST) Message-ID: <0b75eb10-5a48-4bea-a5d1-898c52dcb932@gmail.com> Date: Wed, 29 Jan 2025 15:57:15 +0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Simple query with Planner underestimating rows. To: =?UTF-8?Q?Felipe_L=C3=B3pez_Montes?= References: Content-Language: en-AU Cc: "pgsql-performance@lists.postgresql.org" 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 1/29/25 15:32, Felipe López Montes wrote: > Hi, > > Thank you for your reply, > > I have already tried creating such statistics on t3.programme_identifier > and t3.participant_identifier and the plan is the same, however I cannot > create them for the right part of the join as they are from different > tables (t1 and t2) Of course, because for now, a join clause can't be estimated by extended statistics. It applies only to a scan filter (clause referencing only one relation). I have meant that with the development patch [1] applied, you may create two statistics on t3(participant_identifier,programme_identifier) and t2(participant_identifier,programme_identifier). These statistics would then be used to estimate the join clause and may resolve the problem. [1] using extended statistics to improve join estimates https://www.postgresql.org/message-id/flat/c8c0ff31-3a8a-7562-bbd3-78b2ec65f16c%40enterprisedb.com -- regards, Andrei Lepikhov