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 1vuqIY-009Fn0-1J for pgsql-performance@arkaria.postgresql.org; Tue, 24 Feb 2026 11:09:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vuqIW-000lYd-3C for pgsql-performance@arkaria.postgresql.org; Tue, 24 Feb 2026 11:09:49 +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 1vuqIW-000lYV-2C for pgsql-performance@lists.postgresql.org; Tue, 24 Feb 2026 11:09:48 +0000 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vuqIT-000000012L8-2EBx for pgsql-performance@postgresql.org; Tue, 24 Feb 2026 11:09:48 +0000 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-48373a4bca3so32518965e9.0 for ; Tue, 24 Feb 2026 03:09:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1771931385; x=1772536185; darn=postgresql.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=3bZ5jvcmglGP5Uh8m1fzO34wh9flY/jP+XOGC2AO8KA=; b=F4QrxyZ323tPFgvlY0/4vFE6ygxEJNEzA//KpPZc/1MtKQQQue/j2HB+wi0LRr/e4W 6rbpVHCQJNBnCd6HRzFrM+mXcNgkjbcVyzYP8Obm+liH3npB11JxBZi/UZBr4q1a55zC QGgYZc1xwoVb27918srssA88iiN5bY+VsurUHEBNC2wR3b6UuyyOlu+TcfQMRstjch5F kXOskHCx4GAehU+lxRDPyc5QAzPnU7RcFNqh0JNX/Xj/etYacAsar7H7cQ2ARAvnFExy sF5wEATXCESDzDq9+cfdzkMFQCOOmMTtGFA029+RbYVcNxyP1gVA6j0thF6vNmVJKLWP CQcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771931385; x=1772536185; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=3bZ5jvcmglGP5Uh8m1fzO34wh9flY/jP+XOGC2AO8KA=; b=W2o/hnlIbh+/WlvUx2NwUK5Uez4sF3XjtdsRazcgFfw6ZYxVLIy+8xXV89CmQ1LBV4 M1F4cR3t1WoUesHl8OIYHEMTBbW4CEiwp40K2Kkca++XUoqlZUv0/TtqHlSLUUjEtfcE fMsHDydd0Pw/wWpY0YtTmqeBY7/DGsTUrA9G/D+nt+43UZ16iT8LxvWvn/b32H4K1XWa i4OR20I4f8SapAFa9zQyIFTSBxNauQTXuAxGVfqhiJ2uriq6Qov3ETTSa5eaI4ih5BzK 3VPq8Pank/WqEMoD1pTvjc3+eS8ERUvRZr5BBEv1sbdDR9kmbkztV7WzO9RJQEZcgJFG PILg== X-Gm-Message-State: AOJu0YyjjCP6WF9QSx1sR76hWtHlZ+qrna6PVLCiMbD62DXrtALufkH8 i4J3tOq5TKeji0lfgcyTkFzpw1nttU76WXyYHxGJ3qM2pOTfFCaoZova X-Gm-Gg: AZuq6aJHIj3pI/VbZ7ULS8BUDDitB3FD/NEaD38RVYQBQjEkUucQK6gpn7uXpp9wwvg YtpinCPDuaTmKNhQeYu7SEaV7IgHgOTnyQlRrKRN2Ui1TTvfjVvhOntciJIjRGYF9qmMZUQhn5k FwiVXgj/UNKdPmtmklMVlR8lwjIMLpKa6d2quROhu+BmdGJXzdf8qr/HDloO0k7fqW5DyQnretR O0+Cc2K78JEF6vqxPlfYbUazK4PAszlDJOkM0pjtdjzCluCfZzkf1RfxXvBSyL57hAA38e8DMWl px9r7UE7JVAKqrbpL8z7z33sdM1pjqzJ1Y+QLC8+X7P5CWsMm9lXU5GP5n1zZDUDQHGYtp9pLHR HaPvGFwZHdKfFhXnCdm0AKzG+sSW+MGgp2qDP4rsImKWAhBo/HUmJl22PggtpxuB/EY8xjJKEtz 5wBBeyd+tOq1LDh40B6rgQTKdkduHj9g/+kUO+746wLvV3Hbjg X-Received: by 2002:a05:600c:4e12:b0:483:1403:c47f with SMTP id 5b1f17b1804b1-483a95bd8bemr172147265e9.6.1771931384986; Tue, 24 Feb 2026 03:09:44 -0800 (PST) Received: from [192.168.15.167] ([80.251.191.198]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43970c00c18sm25468651f8f.14.2026.02.24.03.09.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 24 Feb 2026 03:09:44 -0800 (PST) Message-ID: <0dd76506-053e-4a30-9f95-9dc324e8e1fb@gmail.com> Date: Tue, 24 Feb 2026 12:09:43 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: unstable query plan on pg 16,17,18 To: Attila Soki Cc: pgsql-performance@postgresql.org, Laurenz Albe References: <64ddfe83-317c-4cf1-b04f-cb74d9f40629@gmail.com> <529E2365-6C3F-4BDA-9625-312F3A023C5B@gmx.net> <5bace3e5-3d6b-4f81-92a9-9ff4e9e5de53@gmail.com> <1C445A2F-3256-4F04-B55D-9850581FF39A@gmx.net> Content-Language: en-US From: Andrei Lepikhov In-Reply-To: <1C445A2F-3256-4F04-B55D-9850581FF39A@gmx.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 24/2/26 10:16, Attila Soki wrote: > On 23 Feb 2026, at 21:25, Andrei Lepikhov wrote: >> Thanks. But I meant your 'good' plan built by the PG14. I think a new >> feature invented later has added some problems. >> >> Current conjecture is the following. As I see, the main problem is >> with Right Hash Join: >> -> Hash Right Join (cost=210369.25..210370.30 rows=8 width=99) >> Its inner side (Hash table) is rebuilt multiple times (around 1k) due >> to an external parameter (gauf_1.id) in the subtree. It looks like a >> disaster, and before I thought we don't build hash tables over >> parameterised query trees at all. >> >> So, let me discover a little more, but your PG14 explain could add >> more details here. > > Sorry, I misunderstood that. > here is the pg14.4 explain This update gives us more useful details. In PG14, the join search problem involved at most 9 relations. In PG19, the maximum is now 18 joins. Do you know what your join_collapse_limit is set to? It looks like subplan pull-ups have made things more complex. First, we should look into any possible 'rescan cost' issues on our side as developers. On your end, please check the join_collapse_limit setting. If needed, try increasing it to around 20. This might help. -- regards, Andrei Lepikhov, pgEdge