Re: Function call costs for SQL and PLPgSQL

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Vincenzo Romano <vincenzo(dot)romano(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Function call costs for SQL and PLPgSQL
Date: 2007-06-22 14:46:22
Message-ID: 22065.1182523582@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Vincenzo Romano <vincenzo(dot)romano(at)gmail(dot)com> writes:
> I need to create a huge SQL script to load 20+ M rows in a DB.
> I've been force to wrap the inserts into PG functions.
> I can write them in either SQl or PLPgSQL but don't know
> whether this can make a big difference as far as time of
> overall execution is concerned.

> Somewhere else I've been told that SQL function bodies get "inlined"
> during execution. Is thus correct to consider SQL functions "faster"
> that the conterpart written in PLPgSQL?

Inlining only applies to simple-SELECT SQL functions (ie, pure
functions). For what you're trying to do, I think plpgsql will
be faster as well as more flexible.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Dave Page 2007-06-22 14:49:55 Re: How to install Postgresql on MS Vista?
Previous Message Vincenzo Romano 2007-06-22 14:37:11 Re: [PGSQL 8.2.x] INSERT+INSERT