Error in Tina London Guide?

From: Scott Chilcote <src_at_nt.com>
Date: 1995/10/18
Message-ID: <463qki$llg_at_brtph500.bnr.ca>#1/1


I found the "Guidelines and Good Practice for Developing SQL" by Tina London on an Oracle web server recently, and have learned much from reading it over. A friend where I work came to me recently and showed me a place where it is in error.

Under section 3.4, "Investigate Rewriting the Query", it gives an example query joining two tables, both of which have an index on column "name":

SELECT p.name

FROM      people p,
          job j
WHERE     p.name = j.name(+)
and       j.name is null

This is shown to take the longest of the choices. The next query has it written as

SELECT name

FROM      people
WHERE     name not in
          (SELECT name
           FROM   job)

This is supposed to be much faster, although a correlated subquery is supposed to be faster yet.

My coworker set up a test of this claim and found it to be completely wrong. The first query with the outer join is very fast, at least under Oracle 7.1, and the second one takes forever.

I thought that perhaps Ms. London's version of Oracle might have been V6, since the document is dated 1992. I have access to an Oracle 6.0.36 system, so I set up a similar test myself. There was still no difference -- the first query was much faster than the second! I reran the tests several times, clearing out the query cache by running a different query between each trial. The first one finished in a few seconds; the second one took several minutes (the tables were fairly large, tens of thousands of records). The same was also true for a 7.0.13 system we have.

Can anyone explain how this document could be wrong in this example? I was going to recommend it to our SQL programmers, but now I wonder if there are other reasons to distrust it.

Thanks for any help,

                              Scott C.

--
,____________________________________________________________________________,
||Disclaimer: These opinions / LINUX:\>>"Newbies flame; net vets entertain."||
|| are my own.  Sales have //  Where  \\      > "I'm NOT entertained!"      ||
|| been down lately.     // Freedom Isn't\\     "Please stop flaming..."    ||

`-------------------------==> Virtual! <==-----------------------------------'
Scott Chilcote - AiC/NT/RTP Mail: scottc_at_nando.net
Received on Wed Oct 18 1995 - 00:00:00 CET

Original text of this message