Re: How do a user-defined function that returns a table executes a query?

From: Katsuya Okizaki <miotsukushi0800(at)gmail(dot)com>
To: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: How do a user-defined function that returns a table executes a query?
Date: 2023-02-08 23:10:22
Message-ID: CAAe6QrAhO4s=OTM9JNs7_F0y-qprVjTGw4c_jh6Jt2stUMF75Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Dear Laurenz,

Thank you for your help. As you suspected, I was seeking a way to view the
execution plan of a function defined in SQL. Your suggestion was exactly
what I needed and has been very helpful.

Additionally, I also appreciated learning about the debugging techniques
for PL/pgSQL. Thank you for your valuable advice.

Best regards,

Katsuya Okizaki

2023年2月8日(水) 19:18 Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>:

> On Wed, 2023-02-08 at 08:49 +0900, Katsuya Okizaki wrote:
> > In a normal SQL, we can use the EXPLAIN command to view the execution
> plan.
> > However, in this case, I am not sure how a user-defined function work.
> >
> > If anyone has faced a similar situation and found a way to view the
> execution plan,
> > I would greatly appreciate your insights and suggestions.
>
> I am not sure which of the following you want:
>
> 1. Get the execution plan of SQL statements run inside a function:
>
> For that, you would use "auto_explain" with
> "auto_explain.log_nested_statements = on".
>
> 2. Get a trace of the execution of the function code itself:
>
> For PL/pgSQL, there is "pldebugger" (
> https://github.com/EnterpriseDB/pldebugger),
> which can be used together with pgAdmin.
>
> I usually sprinkle the code with RAISE NOTICE statements.
>
> Yours,
> Laurenz Albe
> --
> Cybertec | https://www.cybertec-postgresql.com
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Martin L. Buchanan 2023-02-09 00:04:20 Boyer-Moore string searching in LIKE, ILIKE, and/or POSITION?
Previous Message Tom Lane 2023-02-08 22:57:04 Re: How to create directory format backup