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.96) (envelope-from ) id 1wDFEZ-002m1v-0i for pgsql-bugs@arkaria.postgresql.org; Thu, 16 Apr 2026 05:25:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wDFEY-003xMS-0I for pgsql-bugs@arkaria.postgresql.org; Thu, 16 Apr 2026 05:25:46 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wDFEX-003xMB-2f for pgsql-bugs@lists.postgresql.org; Thu, 16 Apr 2026 05:25:45 +0000 Received: from mail-dl1-x122a.google.com ([2607:f8b0:4864:20::122a]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wDFEV-00000001M03-1y69 for pgsql-bugs@lists.postgresql.org; Thu, 16 Apr 2026 05:25:45 +0000 Received: by mail-dl1-x122a.google.com with SMTP id a92af1059eb24-12c373ee97fso618151c88.1 for ; Wed, 15 Apr 2026 22:25:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1776317140; cv=none; d=google.com; s=arc-20240605; b=Bs8OEDVj3Y3X/aBHrHwkz5+fA7Nzwq26+vUs471aCrDinbcreo7ndBWwBIVAbpnPFM d/G503Ji3zWZU4ettkQoY0L0V7iW2LeuRF8QFgivrZIDUoOMOnPil5BPz+XjqTsMBr4R bbgkJKqtMuFS8Ey1biIcsU5nZ/cc+r9tyA4stW9d+jPf+tFPcnGnSOP1yABuMuU7a0aB CWWHEJR9bW8pPCFtFblZ3EAVFF8AGf2P4zSQ9WZIVloYlx/OakjvAoVIrNTmfFDlUeSM no0X6quTTOyWYGo6zt+r7cn6Op7nFtocln3eQfRASeQZvk/+vBIi9jT2+PhZBkHLRpTT FfDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Q+2WRxyOBaMNJHqa+6LRSJx7cJnBWAU8DB9q9c3IGh8=; fh=uPrVQuGR53BXW3n2EZXy9n/6FNENN8R7e/OQwP97J68=; b=bTEdvFqPv/wXD1PLpjJ18UgPI+dMCi/iZ4lrs2kTAIHAkPQab6XiFs0ZB6QEi+qQpC iJBSOSIGkEQ0wuw6DkN8oItQ3A3bYZjzdffcfSiBEbXxUEHHFWk2r5jaF3FGIZtseuo7 MaBURbztzkUgpqVsbsq9rz6pQ7wVWUffK6zEfh2FmS69dmQ401r+BCfiPfTs0y4a/4n7 wkzl92Pglf6bNNfH5myXnJ6oVs90l4g1lRolaymhc4n94UZagmP07Le/ULX3aWAD+Vco 0bK+nx7caEcaZ8fYkYGm8xDlLYNtEy+Wq6/qULCmJEdkA8O9Wo6KT3vHgSNhNE0zibIr KJgQ==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776317140; x=1776921940; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Q+2WRxyOBaMNJHqa+6LRSJx7cJnBWAU8DB9q9c3IGh8=; b=S+mlf3hmSu3YjhIdiN5uZtlv2uh4gAA5JnpUcfbyEgCyo2XZLrOyH6cWt2xgNFR2LJ Z5w1Lj4jMYE1f6clnVKTf99BnOkiC7Jd3ibO2i+2lXQxB/XX9T93nwepYgI3LJFkHdIZ SD/75T+Y4b63iiVQzq7cfgPX26NrVbub8ve0dmX3TTAV4/YK6NHoxRuLi7LLFtFZcGlS IH/AcUsl+3nyVYJo3FIBPtpvcDNnzTwY+4UVZ8fTg8flLHOlT2YLJtNctpsMQ9AsrG0l Uo4ojWEKnraflwvo/2pf7mn1JHPgvgnBTLVgk+kSr+I2is0C3DSiNgAsjibZE8nKFEap fATA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776317140; x=1776921940; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Q+2WRxyOBaMNJHqa+6LRSJx7cJnBWAU8DB9q9c3IGh8=; b=Giu/NoRfpAmf8lpoAuzT7eZgiLnAFF53Ibs/aI9PVqRJG6YqpFHwAJQFmOr2EBJUgR Z9TqvR7+b7e4cawx5ZDnaP4UQ9hGJGcp3Dj1JyZw+ta93xF9i4fE6KDbkOMVA41k4/nr yNVwhnllm6TxycHnTq7l1NJtcB7YQG2Lcbl3/uTww4xNyeim9G3rNSTKux0K6WEwKJgo W0FmKTwBR9mKkYiVrKPPyK0RYDN5MOS6Fjp9woN4x08YsRvT6yuYACoqMyH3N4wZhyNb Px3DIFeXI0ATHVPl4IVpjTJroxtlUKouyguKR6ILFhgkABdV1Zoj0+FBx1fXZI0/fMpy 2qNw== X-Forwarded-Encrypted: i=1; AFNElJ8GgrNyp7k6eSQu1saeEMSHXNUaGsZtLTVEgrzwRbxYa9vhRneERP1QdMNgwfbVdTa5y/el59oTSuia@lists.postgresql.org X-Gm-Message-State: AOJu0YwpXrdNvx+ScB/l2h27iFXu7dUzrUsRO7rju6Csx9UCuDOdrITl 0GW84u4AK4hmuvjN27GCDcdErCv5LAWQ7WHgSthtEoxd4shbmKzcw2KnGjpOQeZDdvMIJZJEERg vCeDXeEHfZ3n+MnDZqidNoRdvJKvv9T4wQLH8 X-Gm-Gg: AeBDiesABM78tfljDbBcxyX2wDRBqFH3aQpkQv2tGFKqAzyMl9QLO7u1Vu9vZl4cFju ExwsPSTjDjjI02Od8ggHZJcgd+2JF6ZsPXAtMfYMQDHT2BuK0+qs4tG3DXNaATPxIghwz/o4p6V +a3IC8wWZa5dGTqw7t98JPpKUDLhwYpY9HWVnfGKuUaVSjMb6YNqXIZ4izeF2QGX/kLsN8qr4hT p1YATpx+dtCDLkW4jn4q3QPclK3lCrC4Fu8nb03qHsCA0IohpX1qwuretnRyxMq3Ix74jHLxKWZ hHdtxnvFaqUWjWiRD9vMP7Wvu25a4Cjg+pAGbvdlREUIVTsDryrvKU6sU+tHsyKkK+DFNS+E1j8 = X-Received: by 2002:a05:7301:6091:b0:2da:7e33:9267 with SMTP id 5a478bee46e88-2e19344275dmr226573eec.8.1776317139719; Wed, 15 Apr 2026 22:25:39 -0700 (PDT) MIME-Version: 1.0 References: <19449-4fac687c06cc7def@postgresql.org> <43225458.20260402160627@cern.ch> <94712944.20260402164957@cern.ch> <2747373b-d188-43b1-8e49-66f9e23e3c24@vondra.me> <3675338.1775169816@sss.pgh.pa.us> <9f6b7a6d-62db-4a63-9fb7-5deee702a24f@vondra.me> In-Reply-To: <9f6b7a6d-62db-4a63-9fb7-5deee702a24f@vondra.me> From: Thomas Munro Date: Thu, 16 Apr 2026 17:25:01 +1200 X-Gm-Features: AQROBzDPyPoVCXsCeWLhr_M6FeGQvela2aEDcLVcOveWe4IKCtjAhd-WwveM75M Message-ID: Subject: Re: BUG #19449: Massive performance degradation for complex query on Postgres 16+ (few seconds -> multiple hours) To: Tomas Vondra Cc: Tom Lane , =?UTF-8?Q?Adrian_M=C3=B6nnich?= , Andres Freund , pgsql-bugs@lists.postgresql.org, Tomas Vondra Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Sun, Apr 5, 2026 at 2:45=E2=80=AFAM Tomas Vondra wrote= : > At this point I was suspecting the data distributions for the join > columns may be somewhat weird, causing issues for the hashjoin batching. > For events.contributions.id it's perfectly fine - it's entirely unique, > with each ID having 1 entry. Unsurprisingly, because it's the PK. But > for attachments.folders.contribution_id I see this: > > SELECT contribution_id, count(*) FROM attachments.folders > GROUP BY contribution_id ORDER BY 2 DESC; > > contribution_id | count > -----------------+-------- > | 464515 > 5492978 | 67 > 4117499 | 42 > 4045045 | 41 > ... > > So there's ~500k entries with NULL, that can't possibly match to > anything (right)? I assume we still add them to the hash, though. That's also the conditions required to prevent the "stop-partitioning-it's-not-working" logic from triggering. That thing where we know we need to pick a better lower than 100%. But what? Did this commit help? commit 1811f1af98fb237fdd5adb588cd4b57c433b75f8 Author: Tom Lane Date: Thu Mar 19 15:21:36 2026 -0400 Improve hash join's handling of tuples with null join keys.