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 1vnBzd-003W2g-1G for pgsql-hackers@arkaria.postgresql.org; Tue, 03 Feb 2026 08:42:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vnBzc-0046tL-1R for pgsql-hackers@arkaria.postgresql.org; Tue, 03 Feb 2026 08:42:40 +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 1vnBzb-0046t5-3B for pgsql-hackers@lists.postgresql.org; Tue, 03 Feb 2026 08:42:39 +0000 Received: from mail-4323.protonmail.ch ([185.70.43.23]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1vnBzZ-00000000oDT-11Nk for pgsql-hackers@postgresql.org; Tue, 03 Feb 2026 08:42:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pinaraf.info; s=protonmail; t=1770108155; x=1770367355; bh=TbYX2UJDQ/P9lvP5iSvz7lZiFL84Sdrrh0Z9yYHpeyw=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=j4aeIfeCHnuvgs8jrE47pRylf/Ux/24p/BS2ZDJs6M61KimkVgYcwqW4ROy8scaaQ XYARrpqN0itTjoQMNgtJFSZCEv9NsZ+WjR7zrJiuV5uJ6svSa96ZMVJ65mmawEXGj+ FZTrwM0Cdyv/0A3LZMJpSyQUTaKuAmJrYcoyYjqZsdHk+bo53TzfTkvfOoe6zj2kz2 6e4gancDT07J7ejBbZcdYd316sr56tb3Lyr+gOzrbAIGEltbHOWNeaVA2ORBm2IZNy JcU1m3LUO76Ryr7fCGA1b2t20u0nZUpwiEqnb4zWOfkx5XiLlKaEjObmDiLgroFeK0 XqedmXhWDtVpg== Date: Tue, 03 Feb 2026 08:42:33 +0000 To: Euler Taveira From: Pierre Ducroquet Cc: Jelte Fennema , =?utf-8?Q?=C3=81lvaro_Herrera?= , PostgreSQL Hackers , Andreas Karlsson , Anthonin Bonnefoy , pgsql-hackers , Michael Banck , Christoph Berg Subject: Re: Change default of jit to off Message-ID: In-Reply-To: <56a7e683-434f-4d2d-a7ed-9ddefcf426f4@app.fastmail.com> References: <56a7e683-434f-4d2d-a7ed-9ddefcf426f4@app.fastmail.com> Feedback-ID: 175348558:user:proton X-Pm-Message-ID: 6988abd0e2a8ac6f9cdcce73cea704f20f9a6437 MIME-Version: 1.0 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 Le mardi 3 f=C3=A9vrier 2026 =C3=A0 1:42 AM, Euler Taveira a =C3=A9crit=C2=A0: > On Fri, Jan 30, 2026, at 8:28 AM, Jelte Fennema-Nio wrote: > > > +1 on disabling jit by default. At the FOSDEM Postgres developer meetin= g > > consensus was hugely in favor of changing the default. So attached is a > > trivial patch that does this. > > > As someone that analyzed dozens of cases that JIT performs poorly, I woul= d say > +1. However, I don't think it is a good idea. JIT was introduced in v11 > (defaults to off) and the default was changed to on for v12. As Jeff said= [1] I > also think it was premature. It's been 7 years that JIT is enabled by def= ault > and changing this parameter could surprise users who use JIT to mainly im= prove > runtime from OLAP queries. You can argue that the majority of the workloa= ds are > not composed by analytic queries. Fine. That's not an excuse to perform p= oorly > with a small percentage of these analytic queries. Will you propose enabl= ing it > again after fixing the majority of these performance reports? That will b= e > another source of confusion. > > Since there are some reports exposing these issues and articles discussin= g it, > I would suggest improving the documentation stating that there are issues= in > this area and that they will be resolved in the future. (The documentatio= n > already stated the common issue -- short queries -- in the first paragrap= h [2]. > Maybe we need to be more incisive.) > > Instead, of using the argument that JIT hurts short queries, I would like= to > see other alternative solutions for this JIT issue. The v15 added some co= lumns > to pg_stat_statements that helps us understand if JIT is hurting your que= ries. > I don't have numbers but instead of turning JIT off we should adopt a les= s > invasive solution like increasing the thresholds that triggers it -- > jit_*_above_cost (probably using some pg_stat_statements reports). It is = not a > definitive fix, JIT needs improvement and an idea like making JIT more gr= anular > [3] could restore confidence in it. > > Maybe I'm being too optimistic but this is a similar argument that kept > optimizer hints out of core: hints can reduce the pace of planner improve= ments > since fewer bad query plans are reported due to use of hints to force the > optimal query plan. Although I don't have plans to hack on JIT code but > reports may encourage a few developers to propose changes in this area. Well, I can't say I disagree with the feeling here. llvmjit is good or even great for OLAP, depending on your needs. But for OL= TP, it falls short from delivering. I think that disabling jit completely would be an overkill workaround, and = would argue instead that jit_tuple_deforming should be turned off by defaul= t. Here is my reasoning, feel free to contradict it... :) 1) costs in PostgreSQL is kind of bound to the number of tuples and the num= ber of steps in the plan 2) LLVM compilation and optimization time is bound to the size of the gener= ated code 3) JIT speed benefits are bound to the number of time the code is executed So far so good. But what is troublesome is tuple deforming. It is bound to = a parameter, the number, type and layout of attributes to deform. The gener= ated IR can get huge quickly, leading to surprisingly long compilation time= s. Without optimization, the generated machine code can behave worse than t= he heavily optimized tuple deforming we have when interpreting. My stake here is that we should either: - add a jit_deform_above_cost setting set to a high value, higher than jit_= optimize_above_cost - or switch by default jit_tuple_deforming to off Switching jit to off seems overkill compared to this. I have pending patches to improve the generated deforming code with O0 (mos= tly to get rid of pointless jumps around), I've not measured their full imp= act yet but they should arrive here by the end of the week. I would love being proved wrong here. If you can send me some queries where= llvmjit is slower even without tuple deforming when below jit_optimize_abo= ve_cost, I'd happily work on these to turn things around. Note that I also = have sent a first patch to speed up the generated code for many commonly us= ed functions even with O0... One issue that will always remain is that llvm is out of our control, it ha= s an important maintenace cost and its compilation time can change a lot be= tween releases. But it remains the best option at least for OLAP.