Return-Path: owner-postman
Received: from localhost.Berkeley.EDU (localhost.Berkeley.EDU [127.0.0.1]) by nobozo.CS.Berkeley.EDU (8.6.10/8.6.3) with SMTP id JAA26694 for postgres-redist; Sun, 2 Apr 1995 09:57:39 -0700
Resent-From: POSTGRES mailing list <postman@postgres.Berkeley.EDU>
Resent-Message-Id: <199504021657.JAA26694@nobozo.CS.Berkeley.EDU>
X-Authentication-Warning: nobozo.CS.Berkeley.EDU: Host localhost.Berkeley.EDU didn't use HELO protocol
Sender: owner-postman@postgres.Berkeley.EDU
X-Return-Path: owner-postman
Received: from sangam.ncst.ernet.in (sangam.ncst.ernet.in [144.16.11.1]) by nobozo.CS.Berkeley.EDU (8.6.10/8.6.3) with ESMTP id JAA26684 for <postgres@nobozo.CS.Berkeley.EDU>; Sun, 2 Apr 1995 09:57:35 -0700
Received: (from uucp@localhost) by sangam.ncst.ernet.in (8.6.8.1/8.6.6) with UUCP id WAA11087 for postgres@nobozo.CS.Berkeley.EDU; Sun, 2 Apr 1995 22:27:28 +0530
Received: by henna.iitd.ernet.in (4.1/SMI-4.1-MHS-7.0
 )
	id AA14011; Sun, 2 Apr 95 19:09:24 IST
From: sunay@henna.iitd.ernet.in (Sunay Tripathi)
Message-Id: <9504021339.AA14011@henna.iitd.ernet.in>
X-Organisation: Indian Institute of Technology, New Delhi.
Subject: Query order
To: postgres@postgres.Berkeley.EDU
Date: Sun, 2 Apr 95 19:09:23 GMT+5:30
X-Mailer: ELM [version 2.3 PL0]
Resent-To: postgres-redist@postgres.Berkeley.EDU
Resent-Date: Sun, 02 Apr 95 09:57:39 -0700
Resent-XMts: smtp

Dear friends,

I am running postgres v4r2 on Solaris 2.3. I have a single table in which I
have 6 attributes (all of type text).

Table Name = Info
Attributes (fields) = Name Street City State Zip Country

I also have a user defined function sub_srch which takes as argument two
strings and if the search string is a sub string, it returns true.

Now, I give a simple query

* retrieve (Info.all) where Info.City="CUPERTINO" and Info.State="CA" and
sub_srch(Info.Name, "smith") \g


I want it to find all the smiths in city CUPERTINO in state CA.

Now the question -

How will the query be processed. Will all the records having Info.City =
CUPERTINO be selected first and then of those selected, it will select
the ones that have Info.State = CA and then from those the smiths or . ...

I mean, what is the order. Right now, the postgres backends first selects
all the smith by using my function and then of those selected it checks
for city and state.

For some other queries, it works in reverse order. There has to be some order
while processing the query.

I will be much obliged if anyone can give me some idea. 

Thanks

Sunay Tripathi
Dept. of CSE,
IIT Delhi

==============================================================================
   To add/remove yourself to/from the POSTGRES mailing list: send mail with 
   the subject line ADD or DEL to "postgres-request@postgres.Berkeley.EDU".
   If this fails, send mail to "post_questions@postgres.Berkeley.EDU" and
   a human will deal with it.  DO NOT post to the "postgres" mailing list.
==============================================================================
              URL: http://s2k-ftp.CS.Berkeley.EDU:8000/postgres/
