From: tv@fuzzy.cz
To: Adarsh Sharma <adarsh.sharma@orkash.com>
Cc: Vitalii Tymchyshyn <tivv00@gmail.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Re-Reason of Slowness of Query
Date: Wed, 23 Mar 2011 11:38:23 +0100
Message-ID: <c054efdf315e1df9376b2646077ef805.squirrel@sq.gransy.com> (raw)
In-Reply-To: <4D89C704.5080603@orkash.com>
References: <4D89BABF.4080806@orkash.com>
<4D89BCD6.6040604@gmail.com>
<4D89C704.5080603@orkash.com>
> I just want to retrieve that id 's from page_content which do not have
> any entry in clause2 table.
In that case the query probably does not work (at least the query you've
sent in the first post) as it will return even those IDs that have at
least one other row in 'clause2' (not matching the != condition). At least
that's how I understand it.
So instead of this
select distinct(p.crawled_page_id)
from page_content p, clause2 c where p.crawled_page_id != c.source_id ;
you should probably do this
select distinct(p.crawled_page_id)
from page_content p left join clause2 c on (p.crawled_page_id =
c.source_id) where (c.source_id is null);
I guess this will be much more efficient too.
regards
Tomas
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: pgsql-performance@postgresql.org
Cc: tv@fuzzy.cz, adarsh.sharma@orkash.com, tivv00@gmail.com
Subject: Re: Re-Reason of Slowness of Query
In-Reply-To: <c054efdf315e1df9376b2646077ef805.squirrel@sq.gransy.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox