Re: Adding nextval() to a select caused hang/very slow execution

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Eric Raskin <eraskin(at)paslists(dot)com>
Cc: Michael Lewis <mlewis(at)entrata(dot)com>, Pgsql Performance <pgsql-performance(at)lists(dot)postgresql(dot)org>
Subject: Re: Adding nextval() to a select caused hang/very slow execution
Date: 2020-11-04 21:16:29
Message-ID: 1322417.1604524589@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Eric Raskin <eraskin(at)paslists(dot)com> writes:
> So, things get even weirder. When I execute each individual select
> statement I am generating from a psql prompt, they all finish very
> quickly.
> If I execute them inside a pl/pgsql block, the second one hangs.
> Is there something about execution inside a pl/pgsql block that is
> different from the psql command line?

Generic vs specific plan, perhaps? Are you passing any parameter
values in from plpgql variables?

IIRC, you could force the matter by using EXECUTE, though it's
somewhat more notationally tedious. In late-model PG versions,
plan_cache_mode could help you too.

regards, tom lane

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Koteswara Rao Daliparthi 2020-11-05 02:58:50 Low cost query - running longer
Previous Message Eric Raskin 2020-11-04 20:39:41 Re: Adding nextval() to a select caused hang/very slow execution