Mittwoch, April 25, 2012

Group By Alternativen

Iggy Fernandez hat eine Artikelserie mit dem Titel The Hitchhiker’s Guide to SQL gestartet. Im ersten Teil Lateral derived tables and other alternatives to GROUP BY zeigt er für eine gegebene Query drei Varianten zu GROUP BY:
  • analytische Funktionen
  • skalare Subquery
  • lateral derived table (die ist allerdings not supported)
Er erklärt dabei auch noch mal sehr prägnant, warum es wichtig ist, ein paar Syntaxvarianten zur Verfügung zu haben:
In a perfect world, we could use any of the above variations and it wouldn’t matter because all of them would have the same execution plan for any particular data distribution and hence would always have the same performance. In an imperfect world, we have to choose what works best in our case whether that be GROUP BY or something else. 

Keine Kommentare:

Kommentar veröffentlichen