Re: PostgreSQL Function Language Performance: C vs PL/PGSQL - Mailing list pgsql-performance

From Craig James
Subject Re: PostgreSQL Function Language Performance: C vs PL/PGSQL
Date
Msg-id 4BFD55D5.4040907@emolecules.com
Whole thread Raw
In response to Re: PostgreSQL Function Language Performance: C vs PL/PGSQL  (Stephen Frost <sfrost@snowman.net>)
List pgsql-performance
On 5/26/10 9:47 AM, Stephen Frost wrote:
> * Eliot Gable (egable+pgsql-performance@gmail.com) wrote:
>> Since PostgreSQL is written in C, I assume there is no
>> such additional overhead. I assume that the PL/PGSQL implementation at its
>> heart also uses SPI to perform those executions. Is that a fair statement?
>
> Right, but I also wouldn't expect a huge improvment either, unless
> you're calling these queries a ton, or the queries that you're calling
> from the pl/pgsql are pretty short-lived.
>
> Don't get me wrong, C is going to be faster, but it depends on exactly
> what's going on as to if it's going to be an overall improvment of, say,
> 10%, or a 10-fold improvment. :)

Or a 0.1% improvement, which is more likely.  Or that the PL/PGSQL version is even faster than the C version, because
ifyou do any string regexp in your function, Perl has extremely efficient algorithms, probably better than you have
timeto write in C. 

We use Perl extensively and have never had any complaints.  The database activity completely dominates all queries, and
theperformance of Perl has never even been noticable. 

We use a C functions for a few things, and it is a big nuisance.  Every time you upgrade Postgres or your OS, there's a
chancethe recompile will fail because of changed header files.  Any bugs in your code crash Postgres itself.  We avoid
Cas much as possible (and I love C, been doing it since 1984). 

Craig

pgsql-performance by date:

Previous
From: Grzegorz Jaśkiewicz
Date:
Subject: Re: performance of temporary vs. regular tables
Next
From: tv@fuzzy.cz
Date:
Subject: Re: Random Page Cost and Planner