Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jzL59-0004gv-1M for pgsql-general@arkaria.postgresql.org; Sat, 25 Jul 2020 14:23:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jzL57-0007J9-RN for pgsql-general@arkaria.postgresql.org; Sat, 25 Jul 2020 14:23:21 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jzL57-0007J2-JZ for pgsql-general@lists.postgresql.org; Sat, 25 Jul 2020 14:23:21 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jzL55-0004Wq-LY for pgsql-general@lists.postgresql.org; Sat, 25 Jul 2020 14:23:20 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 06PENE4j672184; Sat, 25 Jul 2020 10:23:14 -0400 From: Tom Lane To: Andres Freund cc: David Rowley , Scott Ribe , PostgreSQL General Subject: Re: bad JIT decision In-reply-to: <20200725001605.vrlncip4fx3esv3b@alap3.anarazel.de> References: <7736C40E-6DB5-4E7A-8FE3-4B2AB8E22793@elevated-dev.com> <629715.1595630222@sss.pgh.pa.us> <20200725001605.vrlncip4fx3esv3b@alap3.anarazel.de> Comments: In-reply-to Andres Freund message dated "Fri, 24 Jul 2020 17:16:05 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <672182.1595686994.1@sss.pgh.pa.us> Date: Sat, 25 Jul 2020 10:23:14 -0400 Message-ID: <672183.1595686994@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Andres Freund writes: > On 2020-07-24 18:37:02 -0400, Tom Lane wrote: >> Yeah. I'm fairly convinced that the v12 defaults are far too low, >> because we are constantly seeing complaints of this sort. > I think the issue is more that we need to take into accoutn that the > overhead of JITing scales ~linearly with the number of JITed > expressions. And that's not done right now. I've had a patch somewhere > that had a prototype implementation of changing the costing to be > #expressions * some_cost, and I think that's a lot more accurate. Another thing we could try with much less effort is scaling it by the number of relations in the query. There's already some code in the plancache that tries to estimate planning effort that way, IIRC. Such a scaling would be very legitimate for the cost of compiling tuple-deconstruction code, and for other expressions it'd kind of amount to an assumption that the expressions-per-table ratio is roughly constant. If you don't like that, maybe some simple nonlinear growth rule would work. regards, tom lane