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 1pmZRf-00087e-KK for pgsql-interfaces@arkaria.postgresql.org; Wed, 12 Apr 2023 12:19:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pmZRe-0001Iy-Dw for pgsql-interfaces@arkaria.postgresql.org; Wed, 12 Apr 2023 12:19:26 +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 1pmZRe-0001Ip-6j for pgsql-interfaces@lists.postgresql.org; Wed, 12 Apr 2023 12:19:26 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1pmZRb-002RAc-Jh for pgsql-interfaces@postgresql.org; Wed, 12 Apr 2023 12:19:25 +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 33CCJFDV826407; Wed, 12 Apr 2023 08:19:16 -0400 From: Tom Lane To: Dave Cramer cc: pgchem pgchem , "pgsql-interfaces@postgresql.org" Subject: Re: C trigger significantly slower than PL/pgSQL? In-reply-to: References: <607407366.2321178.1681284910101@webmail.strato.de> <538907970.2383682.1681299222931@webmail.strato.de> Comments: In-reply-to Dave Cramer message dated "Wed, 12 Apr 2023 08:03:41 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <826405.1681301955.1@sss.pgh.pa.us> Date: Wed, 12 Apr 2023 08:19:15 -0400 Message-ID: <826406.1681301955@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Dave Cramer writes: > Fair. So to answer your question. The C function should be faster. If we exclude basic coding errors (i.e. not really "equivalent" processing) then a possible theory is that plpgsql is being careful to cache a query plan that your C code is causing to be recomputed each time. But yeah, all else being equal plpgsql should be slower. regards, tom lane