Re: calling procedures is slow and consumes extra much memory against calling function

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Amit Khandekar <amitdkhan(dot)pg(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
Subject: Re: calling procedures is slow and consumes extra much memory against calling function
Date: 2020-06-10 11:42:11
Message-ID: CAFj8pRCDTjSgOVm1bGc-XbW9NPT+dRDgLnWzKwHXCkdXhZvtWg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

st 10. 6. 2020 v 12:26 odesílatel Amit Khandekar <amitdkhan(dot)pg(at)gmail(dot)com>
napsal:

> On Sat, 16 May 2020 at 00:07, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
> wrote:
> >
> > Hi
> >
> >>>
> >>> The problem is in plpgsql implementation of CALL statement
> >>>
> >>> In non atomic case - case of using procedures from DO block, the
> expression plan is not cached, and plan is generating any time. This is
> reason why it is slow.
> >>>
> >>> Unfortunately, generated plans are not released until SPI_finish.
> Attached patch fixed this issue.
> >>
> >>
> >> But now, recursive calling doesn't work :-(. So this patch is not enough
> >
> >
> > Attached patch is working - all tests passed
>
> Could you show an example testcase that tests this recursive scenario,
> with which your earlier patch fails the test, and this v2 patch passes
> it ? I am trying to understand the recursive scenario and the re-use
> of expr->plan.
>

it hangs on plpgsql tests. So you can apply first version of patch

and "make check"

> >
> > It doesn't solve performance, and doesn't solve all memory problems, but
> significantly reduce memory requirements from 5007 bytes to 439 bytes per
> one CALL
>
> So now this patch's intention is to reduce memory consumption, and it
> doesn't target slowness improvement, right ?
>

yes. There is a problem with planning every execution when the procedure
was called from not top context.

> --
> Thanks,
> -Amit Khandekar
> Huawei Technologies
>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Odin Ugedal 2020-06-10 11:45:02 Re: [PATCH] Add support for choosing huge page size
Previous Message Amit Kapila 2020-06-10 11:40:49 Re: PATCH: logical_work_mem and logical streaming of large in-progress transactions