Re: C trigger significantly slower than PL/pgSQL?
От | Ernst-Georg Schmid |
---|---|
Тема | Re: C trigger significantly slower than PL/pgSQL? |
Дата | |
Msg-id | 8306edcc-8458-44b3-485b-0725de3c7743@tuschehund.de обсуждение исходный текст |
Ответ на | Re: C trigger significantly slower than PL/pgSQL? (Tom Lane <tgl@sss.pgh.pa.us>) |
Ответы |
Re: C trigger significantly slower than PL/pgSQL?
|
Список | pgsql-interfaces |
> 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
В списке pgsql-interfaces по дате отправления: