Return-Path: owner-postman
Received: from localhost (localhost [127.0.0.1]) by nobozo.CS.Berkeley.EDU (8.6.4/8.6.3) with SMTP id HAA02982 for postgres-dist; Fri, 25 Mar 1994 07:01:42 -0800
Resent-From: POSTGRES mailing list <postman@postgres.Berkeley.EDU>
Resent-Message-Id: <199403251501.HAA02982@nobozo.CS.Berkeley.EDU>
X-Authentication-Warning: nobozo.CS.Berkeley.EDU: Host localhost didn't use HELO protocol
Sender: owner-postman@postgres.Berkeley.EDU
X-Return-Path: owner-postman
Received: from nlm.nih.gov (lhc.nlm.nih.gov [130.14.1.128]) by nobozo.CS.Berkeley.EDU (8.6.4/8.6.3) with SMTP id HAA02973 for <postgres@postgres.berkeley.edu>; Fri, 25 Mar 1994 07:01:39 -0800
Received: from hume.csb (hume.nlm.nih.gov) by nlm.nih.gov (4.1/SMI-4.0)
	id AA00237; Fri, 25 Mar 94 10:01:37 EST
Received: by hume.csb (4.1/SMI-4.1)
	id AA10406; Fri, 25 Mar 94 10:05:56 EST
Date: Fri, 25 Mar 94 10:05:56 EST
From: suresh@nlm.nih.gov (Suresh Srinivasan)
Message-Id: <9403251505.AA10406@hume.csb>
To: postgres@postgres.Berkeley.EDU
Subject: Retrieve question
Cc: rodgers@hume.nlm.nih.gov
Resent-To: postgres-dist@postgres.Berkeley.EDU
Resent-Date: Fri, 25 Mar 94 07:01:41 -0800
Resent-XMts: smtp

Folks, here's a naive question on how the
query optimizer works.

It seems that if the query is qualified by
even a simple Boolean expression, the search
defaults to a sequential scan rather than
use the index.  For example,

Given:

  create Word (wd = text) \g
  define index WdInd on Word using btree (wd text_ops) \g

the query:

  retrieve (w.all) from w in Word, where w.wd = "foo"
    or w.wd = "bar" \g

does not use the index at all.  It is actually
much faster to do:

  retrieve into tmp1 (w.all) from w in Word, where w.wd = "foo" \g
  retrieve into tmp2 (w.all) from w in Word, where w.wd = "bar" \g
  append tmp1 (tmp2.all) \g

Can somebody confirm this?  Thanks,

--Suresh
