Re: Query Tunning related to function - Mailing list pgsql-performance

From David G. Johnston
Subject Re: Query Tunning related to function
Date
Msg-id CAKFQuwYuRptm3SrSomOFgbA8gvgyHc_g8MEGmEjV_gJoMitccA@mail.gmail.com
Whole thread Raw
In response to RE: Query Tunning related to function  ("Kumar, Mukesh" <MKumar@peabodyenergy.com>)
List pgsql-performance
On Sun, Apr 17, 2022 at 8:53 AM Kumar, Mukesh <MKumar@peabodyenergy.com> wrote:

We request you to please provide some assistance on below issue and it is impacting the migration project.


I suggest you try and re-write the loop-based function into a set-oriented view.

Specifically, I think doing: "array_agg(DISTINCT paymenttype)" and then checking for various array results will be considerably more efficient.

Or do a combination: write the set-oriented query in an SQL function.  You should not need pl/pgsql for this and avoiding it should improve performance.

David J.

p.s., The convention on these lists is to inline post and remove unneeded context.  Or at least bottom post.

pgsql-performance by date:

Previous
From: Tom Lane
Date:
Subject: Re: Query Planner not taking advantage of HASH PARTITION
Next
From: Benjamin Tingle
Date:
Subject: Re: Query Planner not taking advantage of HASH PARTITION