Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id EEE5B1337BC8 for ; Wed, 23 Mar 2011 07:37:51 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 09030-02 for ; Wed, 23 Mar 2011 10:37:42 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-fx0-f46.google.com (mail-fx0-f46.google.com [209.85.161.46]) by mail.postgresql.org (Postfix) with ESMTP id 76B271337BD5 for ; Wed, 23 Mar 2011 07:37:40 -0300 (ADT) Received: by fxm17 with SMTP id 17so7198716fxm.19 for ; Wed, 23 Mar 2011 03:37:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-type; bh=+lBaUr3b9mSNbGMu3vI/Rk9kRBtrf6ZcZycEPb2QyPQ=; b=a5h8ysF3ojQXPBMXycD+SIc7t9kzTEgTp5kdQMeilaqXffQzjuqX9FopCXS+FBj0Gc cE+YjJfNlSiHU6SOUI1hJ1HYlKMfODc/d57B1bB/BW0CDnCeup2bteXNwZvmuCzW26NA 5GotZwgaRk84l+6VZSigzajlvIoxH8/R0vSe8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type; b=jeA+mNZRPGyaQfK/FqB9knSaTgpZ9SqFp3pd/cT6Q1JRaeYenaX1lHWdKLqPdZrqQA gMtVoyrFzlRBpx0YPiXIJqyQN6N2Au6Pv/AzY0Bp8BAWuo+WpAIDx+ugqI/IeYCXHb1u ANI4Sz6sGcYWJ65k9wLFM3pZEz2HIhK16xZfQ= Received: by 10.223.112.83 with SMTP id v19mr7748263fap.122.1300876659801; Wed, 23 Mar 2011 03:37:39 -0700 (PDT) Received: from [10.1.1.57] (skuns.zoral.com.ua [91.193.166.194]) by mx.google.com with ESMTPS id l4sm1787111fan.38.2011.03.23.03.37.38 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 23 Mar 2011 03:37:38 -0700 (PDT) Message-ID: <4D89CD86.4000008@gmail.com> Date: Wed, 23 Mar 2011 12:37:58 +0200 From: Vitalii Tymchyshyn User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.14) Gecko/20110223 Lightning/1.0b2 Thunderbird/3.1.8 MIME-Version: 1.0 To: Adarsh Sharma CC: pgsql-performance@postgresql.org Subject: Re: Re-Reason of Slowness of Query References: <4D89BABF.4080806@orkash.com> <4D89BCD6.6040604@gmail.com> <4D89C704.5080603@orkash.com> <4D89C778.6050805@gmail.com> <4D89C926.8050009@orkash.com> In-Reply-To: <4D89C926.8050009@orkash.com> Content-Type: multipart/alternative; boundary="------------040806050304090206080208" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.345 tagged_above=-10 required=5 tests=BAYES_00=-1.9, FREEMAIL_ENVFROM_END_DIGIT=1.553, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 201103/265 X-Sequence-Number: 42944 This is a multi-part message in MIME format. --------------040806050304090206080208 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 23.03.11 12:19, Adarsh Sharma ???????(??): > Vitalii Tymchyshyn wrote: >> 23.03.11 12:10, Adarsh Sharma ???????(??): >>> I just want to retrieve that id 's from page_content which do not >>> have any entry in clause2 table. >>> >> Then >> select distinct(p.crawled_page_id) from page_content p >> where NOT EXISTS (select 1 from clause2 c where c.source_id = >> p.crawled_page_id); >> is correct query. >> > > I can't understand how*select 1 from clause2 c where c.source_id = > p.crawled_page_id works too, *i get my output . > > What is the significance of 1 here. No significance. You can put anything there. E.g. "*". Simply arbitrary constant. Exists checks if there were any rows, it does not matter which columns are there or what is in this columns. Best regards, Vitalii Tymchyshyn --------------040806050304090206080208 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 23.03.11 12:19, Adarsh Sharma написав(ла):
Vitalii Tymchyshyn wrote:
23.03.11 12:10, Adarsh Sharma написав(ла):
I just want to retrieve that id 's from page_content which do not have any entry in clause2 table.

Then
select distinct(p.crawled_page_id) from page_content p
 where NOT EXISTS (select 1 from  clause2 c where c.source_id = p.crawled_page_id);
is correct query.


I can't understand how select 1 from  clause2 c where c.source_id = p.crawled_page_id works too, i get my output .

What is the significance of 1 here.
No significance. You can put anything there. E.g. "*". Simply arbitrary constant. Exists checks if there were any rows, it does not matter which columns are there or what is in this columns.

Best regards, Vitalii Tymchyshyn

--------------040806050304090206080208--