Re: Correct query for monitor - Mailing list pgsql-general

From Laurenz Albe
Subject Re: Correct query for monitor
Date
Msg-id 5f7b22937061ee8cbe0df08930b6ef2c93624095.camel@cybertec.at
Whole thread Raw
In response to Re: Correct query for monitor  (veem v <veema0000@gmail.com>)
List 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



pgsql-general by date:

Previous
From: Ron Johnson
Date:
Subject: Re: Correct query for monitor