Re: Correct query for monitor

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: veem v <veema0000(at)gmail(dot)com>, Ron Johnson <ronljohnsonjr(at)gmail(dot)com>, pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Correct query for monitor
Date: 2025-09-27 06:37:59
Message-ID: 5f7b22937061ee8cbe0df08930b6ef2c93624095.camel@cybertec.at
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sat, 2025-09-27 at 01:45 +0530, veem v wrote:
> If we want to identify, what exact query inside a procedure is taking a longer time:
> - Using any pg_* views, Is there an easy way to tie the query_id of the procedure
> with the query_ids of the internal sqls(those are executed within the procedure)
> to quickly get the culprit sql?

No, you have to read the function body. Then you can look for the statements therein
in pg_stat_statements.

> And say , we got the sql and saw a bad plan and we want to change the plan or attach
> a good plan to that query , is there a possible way to do that in postgres?

No, there isn't. You can use the pg_hint_plan extension and its query hints to force
a certain execution plan.

Yours,
Laurenz Albe

In response to

Browse pgsql-general by date

  From Date Subject
Previous Message Ron Johnson 2025-09-26 23:00:13 Re: Correct query for monitor