Re: How to get Relation tuples in C function

Поиск
Список
Период
Сортировка
От Michael Paquier
Тема Re: How to get Relation tuples in C function
Дата
Msg-id YCkP2zvJ1JY1qh++@paquier.xyz
обсуждение исходный текст
Ответ на Re: How to get Relation tuples in C function  (Andy Fan <zhihui.fan1213@gmail.com>)
Ответы Re: How to get Relation tuples in C function  (Andy Fan <zhihui.fan1213@gmail.com>)
Список pgsql-hackers
On Sun, Feb 14, 2021 at 09:29:08AM +0800, Andy Fan wrote:
> Thank you tom for the reply.  What would be the difference between the
> SPI and "write a pure SQL UDF" and call it with DirectFunctionCall1? I
> just ran into a similar situation some days before.   Currently I think
> DirectFunctionCall1 doesn't need to maintain a connection but SPI has to
> do that.

Hard to say without knowing your use case.  A PL function is more
simple to maintain than a C function, though usually less performant
from the pure point of view of its operations.  A SQL function could
finish by being inlined, allowing the planner to apply optimizations
as it would know the function body.  Going with SPI has the advantage
to have code able to work without any changes across major versions,
which is a no-brainer when it comes to long-term maintenance.
--
Michael

Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Michael Paquier
Дата:
Сообщение: Re: pg_cryptohash_final possible out-of-bounds access (per Coverity)
Следующее
От: "Joel Jacobson"
Дата:
Сообщение: Re: Some regular-expression performance hacking