home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / database / 6349 < prev    next >
Encoding:
Internet Message Format  |  1992-08-26  |  1.9 KB

  1. Xref: sparky comp.databases:6349 comp.databases.theory:402 comp.databases.oracle:1388
  2. Path: sparky!uunet!stanford.edu!rutgers!uwvax!hellers
  3. From: hellers@wisc.edu (Joseph Hellerstein)
  4. Newsgroups: comp.databases,comp.databases.theory,comp.databases.oracle
  5. Subject: Re: Is this a bug or a limitation of the SQL language
  6. Message-ID: <HELLERS.92Aug26152713@cleo.wisc.edu>
  7. Date: 26 Aug 92 21:27:13 GMT
  8. References: <1992Aug23.074048.16681@prism.poly.edu> <1992Aug24.100941.24827@dk.oracle.com>
  9.     <JOEY.92Aug24091348@elysium.berkeley.edu>
  10.     <BtJKIG.2K5@watdragon.uwaterloo.ca>
  11.     <HELLERS.92Aug25181305@cleo.wisc.edu>
  12.     <BtLuFp.Kp6@watdragon.uwaterloo.ca>
  13. Sender: news@cs.wisc.edu (The News)
  14. Organization: UW-Madison
  15. Lines: 25
  16. In-Reply-To: gnpaulle@maytag.uwaterloo.ca's message of Wed, 26 Aug 1992 19:07:00 GMT
  17.  
  18. In article <BtLuFp.Kp6@watdragon.uwaterloo.ca> gnpaulle@maytag.uwaterloo.ca (Glenn Paulley) writes:
  19.  
  20. >   > In article <BtJKIG.2K5@watdragon.uwaterloo.ca> gnpaulle@maytag.uwaterloo.ca (Glenn Paulley) writes:
  21. >   >    > [I wrote:]
  22. >   >    >   |select * from emp 
  23. >   >    >   |where salary between
  24. >   >    >   |(select salary from emp where ename = 'Larry')
  25. >   >    >   |and
  26. >   >    >   |(select salary from emp where ename = 'John')
  27. >   > 
  28. >   >    > You want to avoid subqueries whenever possible.  To get what you need,
  29. >   >    > try the following:
  30. >   > 
  31. >   However, the scalar subqueries above are not correlated, so
  32. >   I still fail to see how join processing could perform better than (basically)
  33. >   a single scan- nested loops aren't required. Again, I'm assuming that 
  34. >   ename is indexed, or in some way it's possible to determine Larry 
  35. >   and John's salary quickly.
  36.  
  37. You're right -- in this example, since the subqueries are scalar and
  38. not correlated, the expression above is as good as any other.  My
  39. error.  It's still a healthy knee-jerk reaction to convert subqueries
  40. to joins, but in this case it doesn't help.
  41.  
  42. Joe Hellerstein
  43.