Re: General question about speed of functions - Mailing list pgsql-general

From
Subject Re: General question about speed of functions
Date
Msg-id c26c73073aca94ed2ba8b9eb905577af@mail.gransy.com
Whole thread Raw
In response to General question about speed of functions  (Brent Friedman <brent@brentfriedman.net>)
List pgsql-general
On Tue, 13 Apr 2010 10:26:04 -0400, Brent Friedman
<brent@brentfriedman.net>
wrote:
> I am starting a project next week that looks like it will involve some
> massive sql rewrites to gain needed performance, and I am looking at
> implementing as many functions as possible.  I haven't worried that much
> about specific implementations in the past, but this project can use any
> performance gains available, so even a five percent difference between a
> function written in c vs pgsql would be helpful.
>
> The apparent choices available for the existing application are to use
> functions in pgsql, php or c.

This greatly depends on the type of processing you're doing. If you perform
a CPU intensive data processing (a lot of math applied to the data), the C
functions may give you tremendous performance gain.

But in most cases the processing consists of calls to the SQL engine and
simple processing of the results, so it will be about as fast as C (and
much easier to develop and maintain).

I have no experience with PL/PHP, but I'd say it will be about as fast as
PL/pgSQL ...

> Any comments about relative performance of using any of those languages
> would be greatly appreciated.

My recommendation is "Pay attention to properly design the schema, and
don't
hesitate to change it during development. Choose one of the languages and
stick with. And the money you save (due to development in a single
language)
invest into better hardware.

Tomas

pgsql-general by date:

Previous
From: Grzegorz Jaśkiewicz
Date:
Subject: Re: optimalisation with EXCEPT clause
Next
From: raghavendra t
Date:
Subject: Re: Dynamic Catalog Views