public inbox for [email protected]  
help / color / mirror / Atom feed
From: Carlos Augusto Machado <[email protected]>
To: [email protected]
Subject: Re: Performance Issue -- "Materialize"
Date: Mon, 21 Aug 2017 19:19:10 +0000
Message-ID: <CAK2MEjur9Mtw+XKAO_DGBXROtLV=84PpNCpuZ7GLenZPt=2Piw@mail.gmail.com> (raw)
In-Reply-To: <CAK2MEjuV+99716Qg7wU8C4LMdYdEXSimzXJ7uf1yH6yhp4e7Qg@mail.gmail.com>
References: <[email protected]>
	<[email protected]>
	<CAK2MEjuV+99716Qg7wU8C4LMdYdEXSimzXJ7uf1yH6yhp4e7Qg@mail.gmail.com>
List-Unsubscribe:  <mailto:[email protected]?body=unsub%20pgsql-performance>

I think you query is a bit confusing and have many subqueries, so I tried
to simplify

If you cant´t have more import_num = 0 to the same login, try this

SELECT count(*)
FROM test_tab tab1
LEFT JOIN test_tab tab2
    ON tab1.login = tab2.login AND tab2.import_num = '0'
WHERE
   tab2.login IS NULL AND
   import_num = '4520440'

otherwise try this

SELECT count(*)
FROM test_tab tab1
LEFT JOIN (
   SELECT DISTINCT login FROM test_tab WHERE import_num = '0'
) tab2
    ON tab1.login = tab2.login
WHERE
   tab2.login IS NULL AND
   import_num = '4520440'


Em seg, 21 de ago de 2017 às 15:47, Carlos Augusto Machado <
[email protected]> escreveu:

>
> Do you have an index on login column ?
>
> If not, try creating an index and taking off those DISTICTs.
>
> Em seg, 21 de ago de 2017 às 15:33, Justin Pryzby <[email protected]>
> escreveu:
>
>> On Sat, Aug 19, 2017 at 10:37:56AM -0700, anand086 wrote:
>> >
>> +-----------------------------------------------------------------------------------------------------------------------------------------------------------+|
>> > QUERY PLAN
>> >
>> |+-----------------------------------------------------------------------------------------------------------------------------------------------------------+|
>> > Aggregate  (cost=351405.08..351405.09 rows=1 width=8)
>>
>> Would you send explain ANALYZE and not just explain ?
>>
>> Justin
>>
>>
>> --
>> Sent via pgsql-performance mailing list ([email protected]
>> )
>> To make changes to your subscription:
>> http://www.postgresql.org/mailpref/pgsql-performance
>>
>


reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected]
  Subject: Re: Performance Issue -- "Materialize"
  In-Reply-To: <CAK2MEjur9Mtw+XKAO_DGBXROtLV=84PpNCpuZ7GLenZPt=2Piw@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox