pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Performance between triggers/functions written in C  and PL/PGSQL
2+ messages / 2 participants
[nested] [flat]

* Performance between triggers/functions written in C  and PL/PGSQL
@ 2003-01-22 02:50 Ludwig Lim <lud_nowhere_man@yahoo.com>
  2003-01-22 18:57 ` Re: Performance between triggers/functions written in C and PL/PGSQL Josh Berkus <josh@agliodbs.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Ludwig Lim @ 2003-01-22 02:50 UTC (permalink / raw)
  To: pgsql-performance

Hi:


   Has anyone done performance comparison between
triggers/functions in C vs. PL/PGSQL?

   What are the drawbacks of functions written using
C?


ludwig.



__________________________________________________
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
http://sbc.yahoo.com



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Performance between triggers/functions written in C and PL/PGSQL
  2003-01-22 02:50 Performance between triggers/functions written in C  and PL/PGSQL Ludwig Lim <lud_nowhere_man@yahoo.com>
@ 2003-01-22 18:57 ` Josh Berkus <josh@agliodbs.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Josh Berkus @ 2003-01-22 18:57 UTC (permalink / raw)
  To: Ludwig Lim <lud_nowhere_man@yahoo.com>; pgsql-performance


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




^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2003-01-22 18:57 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-01-22 02:50 Performance between triggers/functions written in C  and PL/PGSQL Ludwig Lim <lud_nowhere_man@yahoo.com>
2003-01-22 18:57 ` Re: Performance between triggers/functions written in C and PL/PGSQL Josh Berkus <josh@agliodbs.com>

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