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 1pmYIH-0003LY-Cs for pgsql-interfaces@arkaria.postgresql.org; Wed, 12 Apr 2023 11:05:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pmYIG-0001E6-0W for pgsql-interfaces@arkaria.postgresql.org; Wed, 12 Apr 2023 11:05:40 +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 1pmYIF-0001Df-PL for pgsql-interfaces@lists.postgresql.org; Wed, 12 Apr 2023 11:05:39 +0000 Received: from pgintl.fastcrypt.com ([149.56.129.164]) by magus.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1pmYIB-002QSB-TE for pgsql-interfaces@postgresql.org; Wed, 12 Apr 2023 11:05:39 +0000 Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.48]) by pgintl.fastcrypt.com (Postfix) with ESMTPSA id B6C7D20030 for ; Wed, 12 Apr 2023 07:05:33 -0400 (EDT) Received: by mail-ej1-f48.google.com with SMTP id q23so18301759ejz.3 for ; Wed, 12 Apr 2023 04:05:33 -0700 (PDT) X-Gm-Message-State: AAQBX9frzf+wGOO4ZjVm1pKIIPT6ozwiEqLjEyZUMIP4I2+EYI1s0JAn ip5JoFQ7j5SLydN0FKd3PzCALN0d0T5iovSSuig= X-Google-Smtp-Source: AKy350ZSD4V1l4j17EoqHobkMVj2Zz18QSLO9oebfIOcMf6ApkDFitwRWwwtHKKgU+tasiwNYg/HdmJCLSsnSNp8HdI= X-Received: by 2002:a17:906:9519:b0:932:38d5:ff86 with SMTP id u25-20020a170906951900b0093238d5ff86mr3063459ejx.5.1681297532610; Wed, 12 Apr 2023 04:05:32 -0700 (PDT) MIME-Version: 1.0 References: <607407366.2321178.1681284910101@webmail.strato.de> In-Reply-To: <607407366.2321178.1681284910101@webmail.strato.de> From: Dave Cramer Date: Wed, 12 Apr 2023 07:05:14 -0400 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: C trigger significantly slower than PL/pgSQL? To: pgchem pgchem Cc: "pgsql-interfaces@postgresql.org" Content-Type: multipart/alternative; boundary="000000000000318c1605f92196f0" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000318c1605f92196f0 Content-Type: text/plain; charset="UTF-8" On Wed, 12 Apr 2023 at 06:14, pgchem pgchem wrote: > Hello all, > > I have a functionally identical trigger function in PL/pgSQL and C. Now, > that the C version is about 3x _slower_ (~1500 vs. ~4500 TPS in pgbench) > than PL/pgSQL comes somewhat unexpected. > > It can very well be, that I made a mistake on the C side, but before > everything else, I'd like to ask if this may be expected behavior. Is it > plausible that PL/pgSQL is so much faster than C when used in a trigger > function? > It would be infinitely easier to answer this question if you posted both functions and the plans Dave Cramer www.postgres.rocks > best regards > > Ernst-Georg > > --000000000000318c1605f92196f0 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


On Wed, 12 Apr 2023 = at 06:14, pgchem pgchem <pgchem@= tuschehund.de> wrote:
=20 =20 =20
Hello all,
=20
=C2=A0
=20
I have a functionally identical trigger function in PL/pgSQL and C. Now,= that the C version is about 3x _slower_ (~1500 vs. ~4500 TPS in pgbench) t= han PL/pgSQL comes somewhat unexpected.
=20
=C2=A0
=20
It can very well be, that I made a mistake on the C side, but before eve= rything else, I'd like to ask if this may be expected behavior. Is it p= lausible that PL/pgSQL is so much faster than C when used in a trigger func= tion?
It would be infinitely=C2=A0easier to an= swer this question if you posted both functions and the plans=C2=A0

Dave Cramer
www.postgr= es.rocks

=20
=C2=A0
=20
best regards
=20
=C2=A0
=20
Ernst-Georg
=20
=C2=A0
=20
--000000000000318c1605f92196f0--