From: | David Rowley <dgrowleyml(at)gmail(dot)com> |
---|---|
To: | Nagaraj Raj <nagaraj(dot)sf(at)yahoo(dot)com> |
Cc: | Pgsql Performance <pgsql-performance(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Performance issue |
Date: | 2020-06-14 23:55:30 |
Message-ID: | CAApHDvqNnJKNiiMKh0nhUvch311YF0N45PHk-7SEem_iN7aHSg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
On Mon, 15 Jun 2020 at 10:46, Nagaraj Raj <nagaraj(dot)sf(at)yahoo(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Justin Pryzby | 2020-06-15 00:05:16 | Re: Performance issue |
Previous Message | Nagaraj Raj | 2020-06-14 22:45:52 | Performance issue |