Re: Performance issue - Mailing list pgsql-performance

From David Rowley
Subject Re: Performance issue
Date
Msg-id CAApHDvqNnJKNiiMKh0nhUvch311YF0N45PHk-7SEem_iN7aHSg@mail.gmail.com
Whole thread Raw
In response to Performance issue  (Nagaraj Raj <nagaraj.sf@yahoo.com>)
List pgsql-performance
On Mon, 15 Jun 2020 at 10:46, Nagaraj Raj <nagaraj.sf@yahoo.com> wrote:
> CREATE TABLE test1
> (
...

>     CONSTRAINT pk_i_entity_proxy_id PRIMARY KEY (individual_entity_proxy_id)
>
> );

> CREATE TABLE test2
> (
...

>     CONSTRAINT pk_entity_proxy_id PRIMARY KEY (individual_entity_proxy_id)
> );
>
>
> User query:
>
> explain analyze select COUNT(*) as "DII_1"
>   from ( select distinct table0."individual_entity_proxy_id" as "INDIVIDUAL_ENTITY_PROXY_ID"
>                                 from test1 table0
>                                 inner join test2 table1
>                                 on table0."individual_entity_proxy_id" = table1."individual_entity_proxy_id"

Why do you use "select distinct". It seems to me that you're putting a
distinct clause on the primary key of test1 and joining to another
table in a way that cannot cause duplicates.

I imagine dropping that distinct will speed up the query quite a bit.

David



pgsql-performance by date:

Previous
From: Nagaraj Raj
Date:
Subject: Performance issue
Next
From: Justin Pryzby
Date:
Subject: Re: Performance issue