Re: User Defined Functions/AM's inherently slow?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Eric Ridge <ebr(at)tcdi(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: User Defined Functions/AM's inherently slow?
Date: 2004-01-19 00:28:55
Message-ID: 6903.1074472135@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

>> Theory B would be that there's some huge overhead in calling
>> non-built-in functions on your platform.

I've done some profiling and convinced myself that indeed there's pretty
steep overhead involved in fmgr_info() for a "C"-language function.
Much of it isn't platform-dependent either --- as best I can tell,
the lion's share of the time is being eaten in
expand_dynamic_library_name(). In scenarios where a function is called
many times per query, we cache the results of fmgr_info() ... but we do
not do so for operations like ambeginscan that are done just once per
query.

Every other function language uses shortcuts or caching to reduce the
cost of fmgr_info() lookup; external C language is the only one that
hasn't been optimized in this way. I shall see what I can do about that.
ISTM we can have a hash table that maps function OID to function address
using the same sorts of techniques that plpgsql et al use.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Eric B.Ridge 2004-01-19 03:20:46 Re: User Defined Functions/AM's inherently slow?
Previous Message Kurt Roeckx 2004-01-18 22:07:01 Re: feature request... case sensitivity without double quotes