Re: How to get Relation tuples in C function

From: Andy Fan <zhihui(dot)fan1213(at)gmail(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Patrick Handja <patrick(dot)bungama(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: How to get Relation tuples in C function
Date: 2021-02-17 01:07:50
Message-ID: CAKU4AWr3sncK8UgM6Kn_Di72e7h_ZgEwg3DYcpgy0vjyj3SQPQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Feb 14, 2021 at 7:56 PM Michael Paquier <michael(at)paquier(dot)xyz> wrote:

> 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
>

Thank you Michael for the response.

--
Best Regards
Andy Fan (https://www.aliyun.com/)

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Nancarrow 2021-02-17 01:44:15 Re: Parallel INSERT (INTO ... SELECT ...)
Previous Message Jacob Champion 2021-02-17 01:02:15 Re: Support for NSS as a libpq TLS backend