Re: Function Question - Inserting into a table with foreign constraints - Mailing list pgsql-general

From Raymond O'Donnell
Subject Re: Function Question - Inserting into a table with foreign constraints
Date
Msg-id 4EB55534.9000005@iol.ie
Whole thread Raw
In response to Re: Function Question - Inserting into a table with foreign constraints  (Brandon Phelps <bphelps@gls.com>)
List pgsql-general
On 05/11/2011 14:46, Brandon Phelps wrote:
>
> With the method you outlined will I notice any huge performance
> impacts?  The application would be parsing incoming data from another
> 3rd party application and could, at times, be executing the function in
> very fast succession, although never twice at the exact same moment
> (single threaded application, pending events will just block until
> they're up).

I honestly don't know... your best bet would be to benchmark and see.
I'd guess that any changes to the code within the function would have
less effect than local conditions - disk I/O, processor speed, etc.

AIUI, putting your code into a function has the advantage that the
Potgres only has to load pl/pgsql and parse the function once for any
given connection, and then the plan is reused for all subsequent
invocations coming from that connection.

If the function is only going to be called once per connection, then you
have the overhead of loading pl/pgsql each time it is called, on top of
parsing the function; so you might be better off trying to do this
outside of a function altogether.

Ray.

--
Raymond O'Donnell :: Galway :: Ireland
rod@iol.ie

pgsql-general by date:

Previous
From: Stuart Bishop
Date:
Subject: Re: Excessive planner time for some queries with high statistics
Next
From: "Andrus"
Date:
Subject: How to find owning schema in function