Re: Query with correlated join having slow performance

2019-12-09 Thread Pavel Stehule
po 9. 12. 2019 v 21:05 odesílatel saket bansal napsal: > Thank you Michael. I re-wrote it and it does perform well. Modified query > at: > > > https://github.com/bansalsaket/PG_correlated_subquery_slowness/blob/master/Modified%20query%20-%20performs%20faster.txt > > Our app team is checking with

Re: Query with correlated join having slow performance

2019-12-09 Thread saket bansal
Thank you Michael. I re-wrote it and it does perform well. Modified query at: https://github.com/bansalsaket/PG_correlated_subquery_slowness/blob/master/Modified%20query%20-%20performs%20faster.txt Our app team is checking with their vendor whether this can be modified at source code level or not

Re: Query with correlated join having slow performance

2019-12-09 Thread saket bansal
Thanks Justin for pointing this out. More work for optimizer for nothing, I will remove it. On Mon, Dec 9, 2019 at 2:48 PM Justin wrote: > Hi Saket > > The first filter condition seems to be duplicated it appears this can be > simplified from > > and ( pdtaltrelt0_.status_typ_dbky=102 >

Re: Query with correlated join having slow performance

2019-12-09 Thread Justin
Hi Saket The first filter condition seems to be duplicated it appears this can be simplified from and ( pdtaltrelt0_.status_typ_dbky=102 and ( pdtaltrelt0_.rule_status_typ_dbky is null ) or pdtaltrelt0_.status_typ_dbky in ( 19 ) or pdtaltrelt0_.status_typ_dbky in (20 )

Re: Query with correlated join having slow performance

2019-12-09 Thread Michael Lewis
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 tog

Query with correlated join having slow performance

2019-12-09 Thread saket bansal
Hi Postgres Experts, Please help me on a query tuning. Postgres verson: 11.5 This database has been migrated from oracle 12c to postgres. In Oracle query executes in 2-3 secs, but in postgres it hangs forever. There are no transactions at this time, I am stuck at first run after migration. My an