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 1k0BAy-00085M-Fs for pgsql-general@arkaria.postgresql.org; Mon, 27 Jul 2020 22:00:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1k0BAw-0005KK-HQ for pgsql-general@arkaria.postgresql.org; Mon, 27 Jul 2020 22:00:50 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k0BAw-0005KC-9V for pgsql-general@lists.postgresql.org; Mon, 27 Jul 2020 22:00:50 +0000 Received: from mail-qk1-x742.google.com ([2607:f8b0:4864:20::742]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1k0BAt-0001Fd-BM for pgsql-general@lists.postgresql.org; Mon, 27 Jul 2020 22:00:49 +0000 Received: by mail-qk1-x742.google.com with SMTP id 2so12724346qkf.10 for ; Mon, 27 Jul 2020 15:00:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=qnKWL/Jgoe+DWg/fOvTWYk89T/m+n7oMK+otyTqiRd4=; b=p3UvFU30c1uMj1XriM2pTevRIKTvmlrSaWRaEb2RsIwvLr2fB+gCwS/TvfeHlCs3wr RjSzEifts2DqunzU7IDeIuQUBcJGwBVLxPws7QH/zIKhh5OXMvvL9w9WAXQtEOQOu78p /9JdcTyvL6cged00Q0yJLYUlDmvkPwPZ3sgw3BkXlO5bCQpBsV5im2IF/JOSryxvA8e0 e6qJLDkzb38CneF25BvXeg84ieNCJWcvYGIx/wUAJ1LvZsbObdoUhY2RituncITGfa9o 7FWg9xIp3GEzyg73hRzX3acrhO6LP9kxKcnRne7O2mo0BjMOKzyaCW9kbJc32NSx1StE 9L+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=qnKWL/Jgoe+DWg/fOvTWYk89T/m+n7oMK+otyTqiRd4=; b=UVsBTHB4XdZbbtukIQuSqE09IyW1ouWGx3jzh8lm+R9WKN3umabBDhoJ1Amt2N840N 1tOfhJDZ4NCuFd2Lx5Ehir/muMinH+q00mPLJbIuvv2XHgt1If+Cr3trSuJGeVuK5NDe qXgZ8VKF5GxSwXjulz8o2chUcsDm7shaPd2T9uzCYmkhbZbj8z05nVL2AG3SdARkGalg f9JP0Hrul9+SD/Cz4ViHnpx03Bk0tGWSuo87q8U0MfH/FDV0xZIWt0qjYY028xnI2nMZ jPiS0HedQrtHcFJuQOgfXbcSexClHkuXOe0gqF/XMgsg1bX3d25+Xyk4wdNy1ZUlB/7I b8gg== X-Gm-Message-State: AOAM533PTv+4FN+LU01SP/8bWyqG8pcLAKgHhIcrpjAI2B/w7yZnhtw0 tjbto77eXP3LYUrYynPNJpfBLw== X-Google-Smtp-Source: ABdhPJzO56B+g8hF4Ei0Rqz+4mGSPzv2qrE4gwr7D0buWLsg3Vs8atdP8K8DXZ87CRqvFhIGmGDGyA== X-Received: by 2002:a37:b484:: with SMTP id d126mr24916242qkf.394.1595887245503; Mon, 27 Jul 2020 15:00:45 -0700 (PDT) Received: from perhan.alvh.no-ip.org ([190.95.19.47]) by smtp.gmail.com with ESMTPSA id m63sm15956159qte.32.2020.07.27.15.00.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jul 2020 15:00:44 -0700 (PDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 542992A1E6E; Mon, 27 Jul 2020 18:00:43 -0400 (-04) Date: Mon, 27 Jul 2020 18:00:43 -0400 From: Alvaro Herrera To: Andres Freund Cc: Tom Lane , David Rowley , Scott Ribe , PostgreSQL General Subject: Re: bad JIT decision Message-ID: <20200727220043.GA29801@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200725001605.vrlncip4fx3esv3b@alap3.anarazel.de> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2020-Jul-24, Andres Freund wrote: > 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. 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. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services