Re: What language is faster, C or PL/PgSQL? - Mailing list pgsql-general

From Merlin Moncure
Subject Re: What language is faster, C or PL/PgSQL?
Date
Msg-id CAHyXU0w_ST+c4tLF0wV67bgXzn_UCWP5pACe8BAD+bDddsaezg@mail.gmail.com
Whole thread Raw
In response to Re: What language is faster, C or PL/PgSQL?  ("Carlo Stonebanks" <stonec.register@sympatico.ca>)
Responses Re: What language is faster, C or PL/PgSQL?  (Bruce Momjian <bruce@momjian.us>)
List pgsql-general
On Sat, Feb 2, 2013 at 11:36 AM, Carlo Stonebanks
<stonec.register@sympatico.ca> wrote:
> Here is an advantage Plpgsql has:
> http://www.postgresql.org/docs/9.1/static/plpgsql-expressions.html
>
> I guess you can offset this by creating your own prepared statements in C=
.
> Otherwise, I can=92t think of how C could be slower. I would choose C for
> functions that don=92t have SQL statements in them =96 e.g. math and stri=
ng
> processing.

For cases involving data processing (SPI calls), C can be slower
because pl/pgsql has a lot of optimizations in it that can be very
easy to miss.  I don't suggest writing backend C functions at all
unless you are trying to interface with a C library to access
functionality currently not exposed in SQL.

merlin

pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: Adding PRIMARY KEY: Table contains duplicated values
Next
From: Alexander Farber
Date:
Subject: Re: Adding PRIMARY KEY: Table contains duplicated values