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 1k0BYA-0000RI-Bf for pgsql-general@arkaria.postgresql.org; Mon, 27 Jul 2020 22:24:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1k0BY9-0004ni-AJ for pgsql-general@arkaria.postgresql.org; Mon, 27 Jul 2020 22:24:49 +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 1k0BY9-0004k4-2V for pgsql-general@lists.postgresql.org; Mon, 27 Jul 2020 22:24:49 +0000 Received: from mailout.easymail.ca ([64.68.200.34]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k0BY6-0008N7-Qh for pgsql-general@lists.postgresql.org; Mon, 27 Jul 2020 22:24:47 +0000 Received: from localhost (localhost [127.0.0.1]) by mailout.easymail.ca (Postfix) with ESMTP id 78001C289C; Mon, 27 Jul 2020 22:24:45 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at emo04-pco.easydns.vpn Received: from mailout.easymail.ca ([127.0.0.1]) by localhost (emo04-pco.easydns.vpn [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id toWCwU8pUrwm; Mon, 27 Jul 2020 22:24:45 +0000 (UTC) Received: from shr-macbook-pro.local (unknown [4.28.96.150]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mailout.easymail.ca (Postfix) with ESMTPSA id 5EBA9C1A97; Mon, 27 Jul 2020 22:24:38 +0000 (UTC) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: bad JIT decision From: Scott Ribe In-Reply-To: <20200727220043.GA29801@alvherre.pgsql> Date: Mon, 27 Jul 2020 16:24:38 -0600 Cc: Andres Freund , Tom Lane , David Rowley , PostgreSQL General Content-Transfer-Encoding: quoted-printable Message-Id: <690D93FA-4A30-422D-94C3-18A089B8AEFE@elevated-dev.com> References: <20200727220043.GA29801@alvherre.pgsql> To: Alvaro Herrera X-Mailer: Apple Mail (2.3608.80.23.2.2) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk > On Jul 27, 2020, at 4:00 PM, Alvaro Herrera = wrote: >=20 > I don't quite understand why is it that a table with 1000 partitions > means that JIT compiles the thing 1000 times. Sure, it is possible = that > some partitions have a different column layout, but it seems an easy = bet > that most cases are going to have identical column layout, and so = tuple > deforming can be shared. (I'm less sure about sharing a compile of an > expression, since the varno would vary. But presumably there's a way = to > take the varno as an input value for the compiled expr too?) Now I > don't actually know how this works so please correct if I = misunderstand > it. I'm guessing it's because of inlining. You could optimize a function = that takes parameters, no problem. But what's happening is inlining, = with parameters, then optimizing.