Re: simple query running for ever

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: Nagaraj Raj <nagaraj(dot)sf(at)yahoo(dot)com>, Pgsql Performance <pgsql-performance(at)lists(dot)postgresql(dot)org>
Subject: Re: simple query running for ever
Date: 2020-06-17 09:23:52
Message-ID: 832b7c51f310e5d9fc35f5f1310a736dba4422a3.camel@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Tue, 2020-06-16 at 20:35 +0000, Nagaraj Raj wrote:
> I wrote a simple query, and it is taking too long, not sure what is wrong in it, even its not giving EXPLAIN ANALYZE.
>
> select T0."physical_address_sid", T0."individual_entity_proxy_id", T2."infrrd_hh_rank_nbr"
> from "cms_prospects".PROSPECT T0
> --inner join "sas_prs_tmp".DEDUPE3583E3F18 T1 on T0."individual_entity_proxy_id" = T1."individual_entity_proxy_id"
> left join "cms_prospects".INDIVIDUAL_DEMOGRAPHIC T2 on T0."individual_entity_proxy_id" = T2."individual_entity_proxy_id"
>
>
> "Merge Left Join (cost=55.96..18147747.08 rows=213620928 width=20)"
> " Merge Cond: (t0.individual_entity_proxy_id = t2.individual_entity_proxy_id)"
> " -> Index Scan using pk_prospect on prospect t0 (cost=0.57..10831606.89 rows=213620928 width=16)"
> " -> Index Only Scan using indxp_individual_demo_infrrd_hh_rank_nbr on individual_demographic t2 (cost=0.57..5013756.93 rows=260652064 width=12)"
>
>
>
> Any suggestions or help would be highly appreciated.

The only potential improvement I can see is to strive for an
"index only scan" on "prospect".

For that, you'd have to add and INCLUDE clause to "pk_prospect"
so that "physical_address_sid" and "individual_entity_proxy_id"
are included and VACUUM the table.

Yours,
Laurenz Albe
--
Cybertec | https://www.cybertec-postgresql.com

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Benjamin Coutu 2020-06-19 15:12:31 Unclamped row estimates whith OR-ed subplans
Previous Message Justin Pryzby 2020-06-16 22:33:30 Re: simple query running for ever