Re: relational algrabra division?

From: -CELKO- <jcelko212_at_earthlink.net>
Date: Tue, 16 Dec 2014 05:20:18 -0800 (PST)
Message-ID: <2ee95849-42f7-4131-b811-01ff157cece8_at_googlegroups.com>


A note on EXISTS(). The use of EXISTS(SELECT *..) versus EXISTS(SELECT <constant>..) should not make a difference in SQL today, but it used to be important! The first versions of Oracle, among others, would actually attempt to return a result set from the subquery.

When we wrote the SQL-89 Standard the EXISTS() was part of the ALL(<subquery>) and [ANY|SOME](<subquery>) predicate family. So the <subquery> had to return a single column table. Yes, I know it looks silly today. The fiction in the standard for SELECT * was that the compiler picked one column and used it. But if you wrote EXISTS(SELECT <constant>..), then the Oracle compiler did not have to find a column and read it, so it was faster.

The myth persisted long after the fact. Today, EXISTS(SELECT *..) is the preferred style. It shows that the predicate applies to a whole row at the table level, and not at the column level. Received on Tue Dec 16 2014 - 14:20:18 CET

Original text of this message