public inbox for pgsql-admin@postgresql.org
help / color / mirror / Atom feedFrom: Tom Lane <tgl@sss.pgh.pa.us>
To: OMPRAKASH SAHU <sahuop2121@gmail.com>
Cc: Ron Johnson <ronljohnsonjr@gmail.com>
Cc: Pgsql-admin <pgsql-admin@lists.postgresql.org>
Subject: Re: performance issue with a PL/pgSQL function
Date: Wed, 15 Apr 2026 01:19:41 -0400
Message-ID: <1931205.1776230381@sss.pgh.pa.us> (raw)
In-Reply-To: <CAOZWJqMxKZ-+bO6f78ak+xFag7n3j_TY9Rs1LypEiRWn39ybow@mail.gmail.com>
References: <CAOZWJqMLq8LiHmSOZXJ0+H0x6XF7RaFvh-eNvVgAn4JeSfcyew@mail.gmail.com>
<CANzqJaCABtV4=GRfEG15msU41-qjno4eA9_wxLYQjgPrs3t26w@mail.gmail.com>
<CAOZWJqPk2UCcS59MeNy1UHC0MW3cKxWzf1CfmXJLo2ioVvtTEQ@mail.gmail.com>
<CANzqJaCXihre4rEYn-FrF1ggDW84Ke81c+YLDg_CRrDje7o7EA@mail.gmail.com>
<CAOZWJqMxKZ-+bO6f78ak+xFag7n3j_TY9Rs1LypEiRWn39ybow@mail.gmail.com>
OMPRAKASH SAHU <sahuop2121@gmail.com> writes:
> I am using a temp table name 5 to 6 times, by storing the data temporarily
> and handing over to other temp and then drop & create temp_table with same
> name to store next temporary data,
That's definitely an anti-pattern. Can you TRUNCATE the temp table
instead of drop-n-recreate?
> Seeing the query plan just by running explain is hectic in case of
> function having more than 4k lines of code, can you please help me if
> there is any tool to check the whole execution plan for a function just
> like we get for a select query.
There's no "whole execution plan" for a function, only for individual
queries within it. You might find auto_explain (with
log_nested_statements turned on) to be useful to capture those query
plans.
regards, tom lane
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-admin@postgresql.org
Cc: tgl@sss.pgh.pa.us, sahuop2121@gmail.com, ronljohnsonjr@gmail.com, pgsql-admin@lists.postgresql.org
Subject: Re: performance issue with a PL/pgSQL function
In-Reply-To: <1931205.1776230381@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox