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 1vDvZM-001Tka-VO for pgsql-performance@arkaria.postgresql.org; Wed, 29 Oct 2025 02:05:48 +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 1vDvZK-00G9Ie-IN for pgsql-performance@arkaria.postgresql.org; Wed, 29 Oct 2025 02:05:45 +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.94.2) (envelope-from ) id 1vDvZK-00G9IV-0s for pgsql-performance@lists.postgresql.org; Wed, 29 Oct 2025 02:05:45 +0000 Received: from relay2-d.mail.gandi.net ([2001:4b98:dc4:8::222]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vDvZG-004ne1-0x for pgsql-performance@postgresql.org; Wed, 29 Oct 2025 02:05:44 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id 3B97541B4B; Wed, 29 Oct 2025 02:05:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vondra.me; s=gm1; t=1761703536; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Farqe6FJfi50qYawqBPNabjfz8rM4dznnvaBplzRxnc=; b=OHjSLuYGZJ8YgJ2Th8nn8tIaLZluuTPk0AKY2EttQTms4C6eaPBwNyHCj1r5QNB5HZyYtq JZLOu0w8imDBqm9dQWF+0SrOvWjNtTEY748xbFbUjvHKHtd27CA5iU2jziDbkb3WIFZCAo bwyzY1T2k74tEwKCpWDB3NhwbYBga3vQRYwLIuIa/JDeuDTF0Mltdn8G4W5e9tCre/T8i3 botrK/zUWxKoN9COlqwxBOj7PKqdvP0yJPgZ36yqZsKyi5sNIUe2n/l3tGi7FeqleLYS/d CCWkXkSUDzLQM6oKEuD4/FxR4t9aNVMSPUn5WV3Eyj/7WSwcUIMuACvn3Gr8eg== Message-ID: Date: Wed, 29 Oct 2025 03:05:34 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: GEQO plans much slower than standard join plans To: Carlo Sganzerla Cc: pgsql-performance@postgresql.org, Rafael Almeida , Leandro Noman References: <3148f6f9-2429-4ee0-9b1e-860aa1578d4f@vondra.me> Content-Language: en-US From: Tomas Vondra In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdduiedvgeekucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuifetpfffkfdpucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddunecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefkffggfgfuvfevfhfhjggtgfesthekredttddvjeenucfhrhhomhepvfhomhgrshcugghonhgurhgruceothhomhgrshesvhhonhgurhgrrdhmvgeqnecuggftrfgrthhtvghrnhepuedvvdeifefffeekudeggfdtieeglefggeduheffveeihefggfehgfdvudetffevnecukfhppeekiedrgeelrddvfedtrddvtdeinecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepkeeirdegledrvdeftddrvddtiedphhgvlhhopegluddtrddufeejrddtrddukegnpdhmrghilhhfrhhomhepthhomhgrshesvhhonhgurhgrrdhmvgdpnhgspghrtghpthhtohepgedprhgtphhtthhopegtrghrlhhosegrlhhuuggvrdgtohhmrdgsrhdprhgtphhtthhopehpghhsqhhlqdhpvghrfhhorhhmrghntggvsehpohhsthhgrhgvshhqlhdrohhrghdprhgtphhtthhopehrrghfrggvlhesrghluhguvgdrtghomhdrsghrpdhrtghpthhtoheplhgvrghnughrohesrghluhguvgdrtghomhdrsghr X-GND-Sasl: tomas@vondra.me List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 10/28/25 16:43, Carlo Sganzerla wrote: >> Another question is whether the difference is in planning or execution. >> I'd expect geqo=on makes planning faster and execution slower, but maybe >> that's not true for your test. It shouldn't be difficult to verify using >> pg_stat_statements (which tracks both plan and exec time). > > We started experimenting and we already see some results that point out > that we have not only better plans, but also faster plans. Our overall > plan load was already somewhat low because of extensive use of prepared > statements, so that in theory also reduces the load of not enabling > GEQO. However, we tested a bit without prepared statements and had > similar results as we did on the test. > I'm not entirely sure I follow what tests you did, some of which might not have been shared on the list. Also, what do you mean by "better plans, but also faster plans"? What's the difference? It seems to me you're implying you get faster planning with geqo=off. That seem counter-intuitive to me, but maybe it can happen. I however don't see any example demonstrating that in the results you shared (and I already suggested what data to look at). > I'm not sure if I'm overstepping here, but wouldn't it be worthwhile to > add a little disclaimer on the docs regarding such cases? I guess that > the hard thing about elaborating database documentation is that you have > to document generically enough so the information makes sense to most > reasonable workloads, so documenting every exception is not a good idea, > but on this case I feel that the docs gave too much the impression that > GEQO *always* improves planning performance. I was thinking of adding a > little "addendum". I've attached a patch for your consideration. > >> I'm not particularly familiar with the GEQO internals, so I can't point >> at specific issues. But I've heard from a couple experienced developers >> that they consider GEQO ineffective / not the right approach. > > In my view, this "addendum" also leaves some room to these other > considerations without compromising readability. > > I'd like to hear your thoughts on that. > Dunno. I'm not convinced geqo=on can increase planning time. Or maybe I don't understand the results you've shared. regards -- Tomas Vondra