Re: Debugging query performance in postgres

From: Ron Johnson <ronljohnsonjr(at)gmail(dot)com>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Debugging query performance in postgres
Date: 2025-09-04 23:21:07
Message-ID: CANzqJaB_1B0YCMCLnY5-y3AS2jcTyzOftc3d9bs6G0On9zeTBg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Sep 4, 2025 at 12:58 PM veem v <veema0000(at)gmail(dot)com> wrote:

> Hello,
> We have a situation in which we had a dml query within a procedure that
> was running fine but suddenly the plan flipped and it started running
> longer.
>

That sounds like something that bit me once. Took a while to figure out,
and was very puzzling.

This list explained the problem and gave me the solution. If you run the
same query multiple times in, after five executions, the PG query optimizer
decides to use a generic plan. This disables that choice to use a generic
plan:

set plan_cache_mode = force_custom_plan;

Setting that returned the procedures to their previously-rapid execution.

--
Death to <Redacted>, and butter sauce.
Don't boil me, I'm still alive.
<Redacted> lobster!

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Dominique Devienne 2025-09-05 08:19:04 Re: Latest patches break one of our unit-test, related to RLS
Previous Message Adrian Klaver 2025-09-04 21:20:34 Re: Debugging query performance in postgres