X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E824552B4F for ; Fri, 29 Jul 2005 01:39:27 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 18912-10 for ; Fri, 29 Jul 2005 04:39:26 +0000 (GMT) Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.194]) by svr1.postgresql.org (Postfix) with ESMTP id 53DEE52B4A for ; Fri, 29 Jul 2005 01:39:23 -0300 (ADT) Received: by zproxy.gmail.com with SMTP id z6so343758nzd for ; Thu, 28 Jul 2005 21:39:23 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:references; b=C1JPfgFGU/zmYZ0Hbmgw0IhfIeR52GFGPBNzamg/bvYTDNzb5Ly7PKIr270oqYGHF8YOVguYkn6HCnE3JFUgEJUdzaPpqrqOHN2lxUjlz1X/Lql5u3Ba/GBELbtq8muWZ2WZebmp6ia7HXFQy9lHLYw4+6so4/87CSqBOhUvyok= Received: by 10.37.22.3 with SMTP id z3mr2408679nzi; Thu, 28 Jul 2005 21:38:49 -0700 (PDT) Received: by 10.36.119.19 with HTTP; Thu, 28 Jul 2005 21:38:49 -0700 (PDT) Message-ID: Date: Fri, 29 Jul 2005 10:08:49 +0530 From: Gnanavel S Reply-To: Gnanavel S To: karim.nassar@acm.org Subject: Re: Two queries are better than one? Cc: pgsql-performance@postgresql.org In-Reply-To: <1122610899.11862.63.camel@localhost.localdomain> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_8206_18523250.1122611929124" References: <1122591866.11860.11.camel@localhost.localdomain> <1122610899.11862.63.camel@localhost.localdomain> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.403 tagged_above=0 required=5 tests=AWL, HTML_50_60, HTML_MESSAGE, RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200507/460 X-Sequence-Number: 13701 ------=_Part_8206_18523250.1122611929124 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On 7/29/05, Karim Nassar wrote: >=20 > On Fri, 2005-07-29 at 09:41 +0530, Gnanavel S wrote: >=20 > > > > Joined: > > > > test=3D> explain analyze > > test-> SELECT cli_name,order.* > > test-> FROM order > > test-> JOIN client ON (ord_client =3D cli_code) > > test-> WHERE ord_batch=3D'343B' AND > > ord_id=3D'12-645'; > > > > where is the cli_code condition in the above query? >=20 > I don't understand the question. ord_client is the client code, and > cli_code is the client code, for their respective tables. batch/id is > unique, so there is only one record from order, and only one client to > associate. >=20 > Clearer? ok. Reason might be comparing with a literal value (previous case) is cheaper= =20 than comparing with column(as it has to be evaluated). But with the previou= s=20 case getting and assigning the cli_code in the application and executing in= =20 db will be time consuming as it includes IPC cost. -- > Karim Nassar >=20 >=20 --=20 with regards, S.Gnanavel Satyam Computer Services Ltd. ------=_Part_8206_18523250.1122611929124 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline

On 7/29/05, Karim Nassar <karim.= nassar@acm.org> wrote:
On Fri, 2005-07-29 at 09:41 +0530, Gnanavel S wrote:

>
>&nb= sp;        Joined:
>
> =         test=3D> explain analyze
&= gt;         test->  &n= bsp; SELECT cli_name,order.*
>     &nbs= p;   test->           =     FROM order
>         test->           =     JOIN client ON (ord_client =3D cli_code)
>    &nb= sp;    test->           =    WHERE ord_batch=3D'343B' AND
>       &nb= sp; ord_id=3D'12-645';
>
> where is the cli_code condition in t= he above query?

I don't understand the question. ord_client is the c= lient code, and
cli_code is the client code, for their respective tables= . batch/id is
unique, so there is only one record from order, and only one client to<= br>associate.

Clearer?

ok.

 Reason might be comparing with a literal value (previous case) is cheaper than comparing with column(as it has to be evaluated).  But with the previous case getting and assigning the cli_code in the application and executing in db will be time consuming as it includes IPC cost.

--
Karim= Nassar <karim.nassar@acm.org >




--
with regard= s,
S.Gnanavel
Satyam Computer Services Ltd. ------=_Part_8206_18523250.1122611929124--