Dave Cramer <davecramer(at)postgres(dot)rocks> writes:
> Fair. So to answer your question. The C function should be faster.
If we exclude basic coding errors (i.e. not really "equivalent"
processing) then a possible theory is that plpgsql is being careful
to cache a query plan that your C code is causing to be recomputed
each time. But yeah, all else being equal plpgsql should be slower.
regards, tom lane