From: Josh Berkus <josh@agliodbs.com>
To: Ludwig Lim <lud_nowhere_man@yahoo.com>
To: PostgreSQL Mailing List <pgsql-performance@postgresql.org>
Subject: Re: Performance between triggers/functions written in C and PL/PGSQL
Date: Wed, 22 Jan 2003 10:57:29 -0800
Message-ID: <200301221057.29207.josh@agliodbs.com> (raw)
In-Reply-To: <20030122025039.18791.qmail@web80302.mail.yahoo.com>
References: <20030122025039.18791.qmail@web80302.mail.yahoo.com>
Ludwig,
> Has anyone done performance comparison between
> triggers/functions in C vs. PL/PGSQL?
On simple ON UPDATE triggers that update an archive table, but are called many
times per minute, about 20:1 in favor of C triggers. Partly that depends on
whether you load the C function as an external file or compile it into the
database. The latter is, of course, faster by far less flexible.
Partly this is because C is fast, being a lower-level language. Partly this
is because the PL/pgSQL parser is in *desperate* need of an overhaul, as it
was written in a hurry and has since suffered incremental development.
> What are the drawbacks of functions written using
> C?
Writing C is harder. Gotta manage your own memory. Plus a badly written C
function can easily crash Postgres, whereas that's much harder to do with
PL/pgSQL.
Usually I just write the original Trigger in PL/pgSQL, test & debug for data
errors, and then farm it out to a crack C programmer to convert to C.
--
-Josh Berkus
Aglio Database Solutions
San Francisco
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-performance@postgresql.org
Cc: josh@agliodbs.com, lud_nowhere_man@yahoo.com
Subject: Re: Performance between triggers/functions written in C and PL/PGSQL
In-Reply-To: <200301221057.29207.josh@agliodbs.com>
References: <20030122025039.18791.qmail@web80302.mail.yahoo.com> <200301221057.29207.josh@agliodbs.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox