> Yeah, there's your problem. Each time through the trigger, that query
> is being parsed, planned, and executed from scratch. plpgsql knows
> how to cache the planned statement, so it's doing less work per-call.
Hello again,
thank you for your help.
I have now used SPI_prepare() and SPI_keepplan() to cache the plan in a
static variable - and now it performs exactly like the PL/pgSQL version.
Which also probably means that either the Trigger is so trivial that C
makes no difference, or the observed TPS limit comes from somewhere else.
I have still a follow-up question, though. Since I'm not calling
SPI_freeplan(), the cached plan lives forever, right? Which is no
problem, since the trigger does the same statement over and over. But
does this generate a memory leak? Or is the saved plan tied to the
session and is deallocated when the session ends?
best regards
Ernst-Georg