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 1tcxZN-003vAi-9K for pgsql-performance@arkaria.postgresql.org; Wed, 29 Jan 2025 02:12:45 +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 1tcxZK-004NUi-RX for pgsql-performance@arkaria.postgresql.org; Wed, 29 Jan 2025 02:12:42 +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 1tcxZK-004NUX-Ha for pgsql-performance@lists.postgresql.org; Wed, 29 Jan 2025 02:12:42 +0000 Received: from mail-il1-x129.google.com ([2607:f8b0:4864:20::129]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tcxZI-0022jX-0n for pgsql-performance@lists.postgresql.org; Wed, 29 Jan 2025 02:12:41 +0000 Received: by mail-il1-x129.google.com with SMTP id e9e14a558f8ab-3cfc934af74so44392855ab.2 for ; Tue, 28 Jan 2025 18:12:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738116760; x=1738721560; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=1MjeCH78sStPC9wksq43pduHLQshT2ojeWeg7PYmjBw=; b=KEeNGUCLaMSSlQEAVMPBJ/SsnYRrufea/Hv72a5DZLqxrn/JlxWNTTyfshNqiLVtxO jDZEum85ttC/cT4BbFBNcqAzAzZVWyvkX8krBQRXi066KICxOvGObryy9W/WBKWd0re2 9AEWmd4CRrkUg8bL7ZdBUIxkSvqHz0v/Ma4fw2e4fYA0sdyDfPDynSc83+abgSHkLBQn VCNhk2CIHhOYjuESRDcO+RCIjssw7Y4hkhS1gFut4KFxZaBaYglYtBB9JzrdMBCha9xn pJcyO48vqF8Q/CuPO4Zd9FSgNO29yNIKxkL1Tn0Yi12JuTC3MGCIKA6fpZcm+TKb+414 EMMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738116760; x=1738721560; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=1MjeCH78sStPC9wksq43pduHLQshT2ojeWeg7PYmjBw=; b=gy8W8/YV5Pwa/68sF7YStAlx++a5WmM6D8baMuKC0QESe0JiYkUv37LfskEE0I2lCB 906FX8vgUrJaT2zYJYoFpLVxcsioVqnOSBjXjl2UnPLFAOIRy7G16aumg+qeQSlXhbGW dWcPJo5WMP/Rs9QF8VlLJz2g1TE9xqMfP/UCdIqrPGxJktESk/kKAj1DEEKKq94rcgxa Ftr3xOzjA/F85nyjETuNsZaG6PBGY7CvrtHEK6YkWK+Cc9k9A83ndpR1d9QnOVQwwY5F jeJ2ebmNYSSi1M5sfhFp0KiqIC7mhhI17zckYEcACTwpMXAoURWPWjp835BQrbLV5mBW vYpA== X-Gm-Message-State: AOJu0YyiImowRvA6l5wTvfHvSfNwONCh2Z+XXhe+X/rgBJSYiQ0AZNA4 2LYcHEuoTyHwdxnKJTf/rZgu4aGxk8TIn3Fgk0l+qU6JfUZWClMBgOMpSKZBiJuAD32XuVlh+mK O+U4GTOc0mMqjZZGDGLK0hDzT0kKhzFRL X-Gm-Gg: ASbGnctcgJgAa8WlId2/DqCY5PwxpUwgGI1Ego1F2am218q331hHwQKwcXfVkarfub5 HM+moBWqW69emeGAvjswJsK4YuFD5jZSmdr0R8gGE7wL0gmYVNW7do4tmxAQSCcE21DCTxANV X-Google-Smtp-Source: AGHT+IGf4rkEXDY7e9cJvam0zMBmA7b9lCHRuTf/d1+kDriZ+DyNmKiFFAWucYyVvZOXqijdRFOdxgg0z7as7s0KC5o= X-Received: by 2002:a05:6e02:1c8a:b0:3a7:88f2:cfa9 with SMTP id e9e14a558f8ab-3cffe3f8b38mr12285465ab.11.1738116759961; Tue, 28 Jan 2025 18:12:39 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Greg Sabino Mullane Date: Tue, 28 Jan 2025 21:12:03 -0500 X-Gm-Features: AWEUYZmRjPZZKVwPnHVL0zTTRhi200uI5nwHp0BpmunMNnT3rBuSkbgfFAQInP4 Message-ID: Subject: Re: Simple query with Planner underestimating rows. To: =?UTF-8?Q?Felipe_L=C3=B3pez_Montes?= Cc: pgsql-performance@lists.postgresql.org Content-Type: multipart/alternative; boundary="0000000000000e4b86062cced888" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000000e4b86062cced888 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Jan 28, 2025 at 5:30=E2=80=AFPM Felipe L=C3=B3pez Montes wrote: > For the sake of clarity and simplicity, I have disabled the nestloop join > in the session because it involved a gather clause and parallel workers a= nd > was still underestimating rows, so the same problem happens with nestloop > strategy too. Instead now the planner goes for a merge join ( if you stil= l > prefer me to send you the nestloop plan, I can do): > Yes, please, send the exact plan you are having problems with. Also, what exactly is the performance issue? It seems your *second best plan* is running in 36 milliseconds? Cheers, Greg P.S. In the future, you can use this to quickly grab relevant settings: select name, current_setting(name) from pg_settings where source <> 'default'; --0000000000000e4b86062cced888 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Tue, Jan 28, 2025 at 5:30=E2=80=AFPM F= elipe L=C3=B3pez Montes <xocas89@gm= ail.com> wrote:
For th= e sake of clarity and simplicity, I have disabled the nestloop join in the = session because it involved a gather clause and parallel workers and was st= ill underestimating rows, so the same problem happens with nestloop strateg= y too. Instead now the planner goes for a merge join ( if you still prefer = me to send you the nestloop plan, I can do):
Yes, please, send the exact plan you=C2=A0are having problems w= ith. Also, what exactly is the performance issue? It seems your *second bes= t plan* is running in 36 milliseconds?

Cheers,
Greg

P.S. In the future, you can use this t= o quickly grab relevant settings:=C2=A0
select name, current_sett= ing(name) from pg_settings where source <> 'default';
--0000000000000e4b86062cced888--