RE: View taking time to show records

From: "Kumar, Mukesh" <MKumar(at)peabodyenergy(dot)com>
To: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>, "pgsql-performance(at)postgresql(dot)org" <pgsql-performance(at)postgresql(dot)org>
Subject: RE: View taking time to show records
Date: 2022-03-25 14:07:28
Message-ID: CH0P221MB0474CF7EA6C4767FD11B707EDE1A9@CH0P221MB0474.NAMP221.PROD.OUTLOOK.COM
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Hi Albe ,

Thanks for the below suggestion , When I ran the query with the parameter , it is taking only 1 sec.

So could you please let me know if I can put this parameter to OFF . at database and it will not create any issues to queries running in database.

Could you please share some light on it.

Thanks and Regards,
Mukesh Kumar

-----Original Message-----
From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
Sent: Friday, March 25, 2022 4:13 PM
To: Kumar, Mukesh <MKumar(at)peabodyenergy(dot)com>; pgsql-performance(at)postgresql(dot)org
Subject: Re: View taking time to show records

On Thu, 2022-03-24 at 15:59 +0000, Kumar, Mukesh wrote:
> We have recently migrated from Oracle to PostgreSQL on version 11.4 on azure postgres PaaS instance.
>  
> There is 1 query which is taking approx. 10 secs in Oracle and when we
> ran the same query it is taking approx. 1 min
>  
> Can anyone suggest to improve the query as from application end 1 min time is not accepted by client.
>  
> Please find the query and explain analyze report from below link
>  
> https://urldefense.com/v3/__https://explain.depesz.com/s/RLJn*stats__;
> Iw!!KupS4sW4BlfImQPd!Ln-8-n9OcKKifiwKjYcs_JOUo80VTTp5hA9V_-gYjOfDr3DDm
> psmbIY_MQxw5RwQ2ZQtMlobbmvex2CIaJtISv0ZkaSn5w$

I would split the query in two parts: the one from line 3 to line 49 of your execution plan, and the rest. The problem is the bad estimate of that first part, so execute only that, write the result to a temporary table and ANALYZE that. Then execute the rest of the query using that temporary table.

Perhaps it is also enough to blindly disable nested loop joins for the whole query, rather than doing the right thing and fixing the estimates:

BEGIN;
SET LOCAL enable_nestloop = off;
SELECT ...;
COMMIT;

Yours,
Laurenz Albe
--
Cybertec | https://urldefense.com/v3/__https://www.cybertec-postgresql.com__;!!KupS4sW4BlfImQPd!Ln-8-n9OcKKifiwKjYcs_JOUo80VTTp5hA9V_-gYjOfDr3DDmpsmbIY_MQxw5RwQ2ZQtMlobbmvex2CIaJtISv1qNNoktA$

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Laurenz Albe 2022-03-26 04:37:38 Re: View taking time to show records
Previous Message Laurenz Albe 2022-03-25 10:43:20 Re: View taking time to show records