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 1olICR-0000Fo-PC for pgsql-general@arkaria.postgresql.org; Wed, 19 Oct 2022 23:10:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1olICO-000131-SR for pgsql-general@arkaria.postgresql.org; Wed, 19 Oct 2022 23:10:08 +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 1olICO-00011l-Ha for pgsql-general@lists.postgresql.org; Wed, 19 Oct 2022 23:10:08 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1olICF-0003TQ-7Y for pgsql-general@lists.postgresql.org; Wed, 19 Oct 2022 23:10:05 +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 29JN9uZt2944322; Wed, 19 Oct 2022 19:09:56 -0400 From: Tom Lane To: Philip Semanchuk cc: PostgreSQL General Subject: Re: Custom function ROWS hint ignored due to inlining? In-reply-to: <76B16E5F-59D0-4C97-8DBA-4B3BB21E2009@americanefficient.com> References: <76B16E5F-59D0-4C97-8DBA-4B3BB21E2009@americanefficient.com> Comments: In-reply-to Philip Semanchuk message dated "Wed, 19 Oct 2022 15:02:42 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <2944320.1666220996.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 19 Oct 2022 19:09:56 -0400 Message-ID: <2944321.1666220996@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Philip Semanchuk writes: > I have a custom function where the ROWS hint is getting ignored. I think= it=E2=80=99s because the function is getting inlined, but I=E2=80=99d lik= e a second opinion. Yeah, I believe you're right about that. > I would prefer to have the function inlined for better performance, but > I can declare it VOLATILE if that=E2=80=99s necessary to give decent est= imates > to the planner. Am I correctly reading the situation? If so, is there > another solution that allows inlining *and* making the ROWS hint visible > to the planner? No, but you could experiment with changing the function to plpgsql instead of SQL. Not sure about the relative performance of those cases, but it's worth trying it both ways. regards, tom lane