Re: Choosing Between PL/PGSQL or C/C++ for Triggers/Store Procs - Mailing list pgsql-general

From Darko Prenosil
Subject Re: Choosing Between PL/PGSQL or C/C++ for Triggers/Store Procs
Date
Msg-id 002901c33058$13cb1f00$7b89bfd5@darko
Whole thread Raw
In response to Choosing Between PL/PGSQL or C/C++ for Triggers/Store Procs  (Clay Luther <claycle@cisco.com>)
List pgsql-general

    IMHO pl/psql triggers are much easier to mantain, not mentioning that triggers are often writen by programers who never learned "C".
    But there are some tasks that You simple can't do with "pl/psql", You have much more "opened" interface to server, and to operating system(try to write function that writes log to some textual file with pl/psql.)
    Few months ago I had to write trigger that generates UPDATE, INSERT or DELETE statements based on executed queries, and trigger should work on any table(no mather table structure). When I tried to write it with pl/psql I realized that this is simple not possible, and switched to "C".
Ok, It took me much more time to write trigger with "C", but once I did, there was no more need to write different function for each table.
 
    If there is some difference in speed for regular functions/triggers, that difference is not significant(I'm speaking from my experience-someone else might think different.). When I say "regular" I mean symple checks and data manipulation.
 
So, I would say :chose the right tool for the task.
 
Regards !
 
----- Original Message -----
Sent: Thursday, June 12, 2003 8:54 PM
Subject: [GENERAL] Choosing Between PL/PGSQL or C/C++ for Triggers/Store Procs

For a very complex database in which we plan to implement database rules via triggers, I need some information on which language, PL/PGSQL or C/C++ provides the most "bang for the buck" with respect to performance. One initially presumes the C/C+ stored procs/triggers will be faster, but after reading some posts on the list about the Query Planner and PL/PGSQL, I was wondering if using PL/PGSQL might not be better.

1) Is there a clear-cut choice when performance is the issue?
2) Is there a fuzzy choice at work here?  Perhaps PL/PGSQL for simple, obvious stored proces/triggers, but C/C++ for complexity?

Thanks.

-- 
Clay
claycle@cisco.com

pgsql-general by date:

Previous
From: Dmitry Tkach
Date:
Subject: Re: need a method to ping a running database
Next
From: Dmitry Tkach
Date:
Subject: Re: Choosing Between PL/PGSQL or C/C++ for Triggers/Store