Re: Re-Reason of Slowness of Query

From: Chetan Suttraway <chetan(dot)suttraway(at)enterprisedb(dot)com>
To: tv(at)fuzzy(dot)cz
Cc: Adarsh Sharma <adarsh(dot)sharma(at)orkash(dot)com>, Vitalii Tymchyshyn <tivv00(at)gmail(dot)com>, pgsql-performance(at)postgresql(dot)org
Subject: Re: Re-Reason of Slowness of Query
Date: 2011-03-23 10:44:22
Message-ID: AANLkTinQTQ+g=fOokh6i7ZqBLoTSVpX_Mfy-7Lo8ndX4@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Wed, Mar 23, 2011 at 4:08 PM, <tv(at)fuzzy(dot)cz> wrote:

> > 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.
>
> true.

> 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.
>
>
This looks like to give expected results. Also note that the where clause
"is null" is really required and is not an
optional predicate.

> regards
> Tomas
>
>
> --
> Sent via pgsql-performance mailing list (pgsql-performance(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-performance
>

--
Regards,
Chetan Suttraway
EnterpriseDB <http://www.enterprisedb.com/>, The Enterprise
PostgreSQL<http://www.enterprisedb.com/>
company.

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Adarsh Sharma 2011-03-23 11:21:17 Re: Re-Reason of Slowness of Query
Previous Message Chetan Suttraway 2011-03-23 10:39:37 Re: Re-Reason of Slowness of Query