Re: function performance vs in-line sql

From: Heikki Linnakangas <heikki(at)enterprisedb(dot)com>
To: "Schwarz, Karl" <Karl(dot)Schwarz(at)ngc(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: function performance vs in-line sql
Date: 2007-03-08 17:52:34
Message-ID: 45F04D62.8090302@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Schwarz, Karl wrote:
> I am having a performance problem with a query implemented within a
> server side function. If I use an SQL client(EMS Postgres) and manually
> generate the sql query I get about 100 times performance improvement
> over using the function.
>
> I've also tried using a prepared statement from my application and
> observed a similar performance improvement over the the function.
>
> The table I am quering against has several hundred thousand records. I
> have indexes defined and I've run vacuum several times.
>
> Is there something basic I am missing here with the use of a function. I
> am no database expert, but my assumption was that a function would give
> me better results than in-line sql.
>
> I've seen a mailing list entry in another list that implied that the
> query planner for a function behaves differently than in-line sql.

For starters, can you show us the function, the manual sql query and the
schema, please?

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Craig A. James 2007-03-08 18:34:06 Re: strange performance regression between 7.4 and 8.1
Previous Message Richard Huxton 2007-03-08 17:49:41 Re: function performance vs in-line sql