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 1w8J0w-000P4k-06 for pgsql-bugs@arkaria.postgresql.org; Thu, 02 Apr 2026 14:27:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w8J0t-006PBk-1k for pgsql-bugs@arkaria.postgresql.org; Thu, 02 Apr 2026 14:27:15 +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.96) (envelope-from ) id 1w8J0t-006PBO-0v for pgsql-bugs@lists.postgresql.org; Thu, 02 Apr 2026 14:27:15 +0000 Received: from fout-b2-smtp.messagingengine.com ([202.12.124.145]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1w8J0r-00000000CP9-3TcX for pgsql-bugs@lists.postgresql.org; Thu, 02 Apr 2026 14:27:14 +0000 Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfout.stl.internal (Postfix) with ESMTP id 4F2F51D0030F; Thu, 2 Apr 2026 10:27:13 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-05.internal (MEProxy); Thu, 02 Apr 2026 10:27:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1775140033; x=1775226433; bh=OjRZlpj1UYMmT0W/M/4ASBd4lruzmPLfA+bCvYBv+6g=; b= H8swGcU8HZ16+YqEv8hR4jIJ4jvtD7oqccKjaYFAQij21dZ0UteZvigSNWE7Jzyr sjbCx4h7RMadriExn4crk0TPgZtxwcwjTi56KbV/B77AlvVcKNKEG/DOvC787+CN OrBE5SHvX/heXOXnDe/IVnz65Trz2nk53E2AIrZkvh5QcdyS2wgxEqcDHtD1Ut8Z B7JFP9yv6dOSctn3r2He5vl4KbfubmntG17rCGKT/9Z2V17KMWJlpg/vjy/q7xTe inryz0UCytJGh6JMnXx1zrOBoeDfH3QfePDSouNFg5sa394Pt48DqTXHb3lh2ZMv fuBzIhngweE1GYLj0DUnUQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1775140033; x= 1775226433; bh=OjRZlpj1UYMmT0W/M/4ASBd4lruzmPLfA+bCvYBv+6g=; b=V q2mUh1YkBeIJ360bUo+RuA5gt6Kr7kkPYowAnYxDP7U2sSLAn31qR4eqXAkkx7dV TPMOVVx6KOIF+sjxD6zPOXd2/+Igp6lNdua/AsCYoS+LwWb6x0VD6yAnduC1sRcT 9UNVeTK2o5A8WRcvGdGFQQmaTnNUtjofX2n2jFJhVcNYXhiHf6TAQyFIXNd6HfeF T6ZJGWH2/0yv7jkuhHkcHzzDsGVp2Hj4CUtCGb5fQ2t4hlUibbVSHPepmXuOsa2g SUWC03uUy6wJ7TWyNlqMnWVgBhBRn7CLZykbB8P3ByzmaJ0081YNeKlkCXSy0TRA NVAOmJWzpbWJnIScq8G0w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgdeivdejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceurghi lhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurh epfffhvfevuffkfhggtggugfgjsehtkefstddttddunecuhfhrohhmpeetnhgurhgvshcu hfhrvghunhguuceorghnughrvghssegrnhgrrhgriigvlhdruggvqeenucggtffrrghtth gvrhhnpeegtdduueefvdfhiedtgfffudeiteduleeljeejvefgfeeileegtddthfejkefg leenucffohhmrghinhepuggvphgvshiirdgtohhmnecuvehluhhsthgvrhfuihiivgeptd enucfrrghrrghmpehmrghilhhfrhhomheprghnughrvghssegrnhgrrhgriigvlhdruggv pdhnsggprhgtphhtthhopeegpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopegrug hrihgrnhdrmhhovghnnhhitghhsegtvghrnhdrtghhpdhrtghpthhtohepthhvsehfuhii iiihrdgtiidprhgtphhtthhopehthhhomhgrshdrmhhunhhrohesghhmrghilhdrtghomh dprhgtphhtthhopehpghhsqhhlqdgsuhhgsheslhhishhtshdrphhoshhtghhrvghsqhhl rdhorhhg X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 2 Apr 2026 10:27:12 -0400 (EDT) Date: Thu, 2 Apr 2026 10:27:12 -0400 From: Andres Freund To: Adrian =?utf-8?Q?M=C3=B6nnich?= Cc: pgsql-bugs@lists.postgresql.org, Tomas Vondra , Thomas Munro Subject: Re: BUG #19449: Massive performance degradation for complex query on Postgres 16+ (few seconds -> multiple hours) Message-ID: References: <19449-4fac687c06cc7def@postgresql.org> <43225458.20260402160627@cern.ch> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <43225458.20260402160627@cern.ch> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 2026-04-02 16:06:27 +0200, Adrian Mönnich wrote: > thanks a lot, I just tried with work_mem set to 128MB on PG16 and it worked fine: > https://explain.depesz.com/s/7Zan > > Likewise on PG18: > https://explain.depesz.com/s/H15B > > And with enable_memoize=0 (PG18, 128MB): > https://explain.depesz.com/s/SaVI That's good. > So increasing work_mem seems like a good workaround for when we upgrade > our production DB. But I guess there's still a but somewhere that results to the > wrong estimate? I don't even know if it's a misestimate that didn't happen in the earlier versions - the join order is different in 14 than it's in the later ones. I don't know why that is at this point. This means that we don't know if 14 would have had the same misestimation if the same join order had been chosen. There also seem to be some data differences: 14: https://explain.depesz.com/s/17Fp#source -> Parallel Seq Scan on contributions contributions_1 (cost=0.00..164891.13 rows=2687413 width=5) (actual time=0.013..454.721 rows=2143186 loops=3) 16: https://explain.depesz.com/s/7Zan -> Parallel Seq Scan on contributions contributions_1 (cost=0.00..37776.28 rows=1643228 width=5) (actual time=0.081..78.499 rows=1314582.00 loops=3) That's a pretty substantial difference in the number of rows. Greetings, Andres Freund