Xref: alice comp.databases.oracle.server:77505
Path: alice!news-feed.fnsi.net!news.idt.net!newsfeed.mathworks.com!cam-news-hub1.bbnplanet.com!washdc3-snh1.gtei.net!news.gtei.net!dfiatx1-snr1.gtei.net.POSTED!not-for-mail
Message-ID: <3853E88A.BAEC7A10@cc.gatech.edu>
From: Paul Bennett <bennett@cc.gatech.edu>
X-Mailer: Mozilla 4.7 [en] (WinNT; U)
X-Accept-Language: en
MIME-Version: 1.0
Newsgroups: comp.databases.oracle.server
Subject: How do you force the order?
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Lines: 29
X-Trace: /KDWjcupNxLKzpu97tAMaS1sp7Ha0CAoqrXOnDhnnPynWoPI37f4uL1iYzhtp34QXVPNgca7wO2/!UeJ9YWqAzcraSAwElRd5eDeRkTPpFrP/BqPCTb6iCZ7n9AQipo+QhDA=
X-Complaints-To: abuse@gte.net
X-Abuse-Info: Please be sure to forward a copy of ALL headers
X-Abuse-Info: Otherwise we will be unable to process your complaint properly
NNTP-Posting-Date: Sun, 12 Dec 1999 18:24:36 GMT
Distribution: world
Date: Sun, 12 Dec 1999 18:24:38 GMT

I have two tables that I am joining, both are about the same size, but I
am naming them below as large and small because when the where is
applied to the JUST the large table, it returns a large set, when the
where is applied to the small table, it returns a small set.

SELECT *
FROM small, large
where small.a = large.a and
small.b = '1' and
large.b = '2';

What I want to do it tell oracle to do the where for the small table
first, because it is going to limit the number of rows dramatically,
then i want it to take that set and do the where on the large table
(which now is a set of only a few rows)

To clarify, I don't want the large.b = '2' to limit rows until after
small.b = '1' limits the rows.  do I have to write the select like this?

SELECT * FROM large
where large.a IN (Select a from small where small.b = '1') and large.b =
'2'

Does this make sense?  Basically, I have SQL statement that is slow
because it is comparing several columns from an entire table instead of
comparing them to a set of rows limited by a join.

Thanks.

