Domanda

This was an exam question , can someone knowledgeable give an answer with an explanation ?

È stato utile?

Soluzione

Most RDBMS products optimize both queries identically.

In SQL Performance Tuning by Peter Gulutzan and Trudy Pelzer, the authors tested six or eight brands of RDBMS and found no significant performance difference between the two different styles of join. There is therefore no preference for one syntax over the other for the sake of performance.

The reasons to use JOIN syntax in the FROM clause are:

  • To allow join types that are not possible in SQL-89 (comma-style) join syntax, such as outer joins, natural joins, USING() clause, etc.

  • To conform to standard SQL-92 syntax. All brands of RDBMS have supported this syntax for years, even Oracle and Microsoft/Sybase, each of which at one time in the past invented their own proprietary syntax for outer joins.

  • To clean up your code, and make it more clear at a glance which join type (inner, outer) you are using, and which terms are join conditions versus which terms are row restriction conditions.

The reasons to use the comma-style syntax instead of the JOIN syntax are:

  • None, unless perhaps if the "J" key on your keyboard is broken. ;-)
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top