Re: Query with correlated join having slow performance - Mailing list pgsql-general

From saket bansal
Subject Re: Query with correlated join having slow performance
Date
Msg-id CACkcRNjenhgKehxktkc8-Fw7dPOL9qqQdxB+MbEE76aYRA-jVQ@mail.gmail.com
Whole thread Raw
In response to Re: Query with correlated join having slow performance  (Michael Lewis <mlewis@entrata.com>)
Responses Re: Query with correlated join having slow performance
List pgsql-general
Thank you Michael. I re-wrote it and it does perform well. Modified query at:


Our app team is checking with their vendor whether this can be modified at source code level or not.
But question remains somewhat valid. Data volume is not huge and original query wasn't very badly written either. Operating system level resources are similar.
Do you know of any bugs associated with using co-related sub queries in postgres. In Oracle, it runs in a sec, while in postgres it does not give result at all , even after 8-9 hours.
I understand both database engines work differently, but such drastic change in performance is a surprise!
We have lot of migrations planned from oracle to postgres, this could be a show stopper. :(
Any suggestions...

On Mon, Dec 9, 2019 at 1:49 PM Michael Lewis <mlewis@entrata.com> wrote:
I'd suggest re-writing your query to avoid ORs whenever possible. Is this generated by an ORM or subject to change with filters selected in application or can you totally control it on DB side?

It may be hugely more performant to simply rewrite this as (almost) the same query twice UNION ALL'd together to separate the productalt1_.alt_pdt_dbky OR productalt1_.orgnl_pdt_dbky conditions.

pgsql-general by date:

Previous
From: saket bansal
Date:
Subject: Re: Query with correlated join having slow performance
Next
From: Pavel Stehule
Date:
Subject: Re: Query with correlated join having slow performance