Query with correlated join having slow performance

Поиск
Список
Период
Сортировка
От saket bansal
Тема Query with correlated join having slow performance
Дата
Msg-id CACkcRNhrQ+aRvm9yokNNPEFeJPF4B3UiC4MphY2ndDxudYRz0A@mail.gmail.com
обсуждение исходный текст
Ответы Re: Query with correlated join having slow performance
Re: Query with correlated join having slow performance
Список pgsql-general
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 analysis:

I have done vacuum full , analyze , even with 100% samples using a much higher value of default_statistics_target.
Also tried different hints using pg_hint_plan extension. Overall cost reduces, but actual run hangs forever.
I think problem is with correlated subquery join condition.
If "and pdtaltrelt%_.tenant_dkby=pdtaltrelt0_.tenant_dkby" condition is removed from both subqueries, result comes in secs(I understand that would be skipping correlated join)

 SQL> select count(*) from pdtalt_rel_to_tenant_rel;
    267216

SQL> select count(distinct tenant_dkby) from pdtalt_rel_to_tenant_rel;
                         3

Table DDLs , query plan and parameter configuration available at below git link:
 
I have 16 GB , 4 CPU , rhel 7 machine.

Thanks for help in advance, let me know if any additional information is required

В списке pgsql-general по дате отправления:

Предыдущее
От: Albrecht Dreß
Дата:
Сообщение: Re: Q: cert authentication and user remapping fails
Следующее
От: Michael Lewis
Дата:
Сообщение: Re: Query with correlated join having slow performance