Sonntag, Juni 22, 2014

Verwendung von SQL Server Query Hints

In der SQL Server Welt betrachtet man Query Hints offenbar ähnlich argwöhnisch wie im Oracle Umfeld - als "best pratice" gilt: man sollte sie vermeiden und alle Entscheidungen dem Optimizer überlassen. Thomas Kejser sieht das ein wenig anders:
For a complete novice of SQL Server, I would agree. But to call avoiding query hints a “best practise” is taking it too far. For anyone with a little experience who knows what they are doing, I find that query hints are not only a good reactive solution, they are a proactive, design time, tool. If I find a stored procedure or query that either
  • A) Gets run often… or
  • B) Is very important and needs to be consistent (“important” is nearly always the same as consistent)
Putting it in simple term: I don’t trust the optimiser with these types of queries. Mission critical queries are much too important to leave in the hands of an unpredictable process like a query optimiser.
Im Anschluss liefert der Autor dann noch eine Klassifikation von Hints, die er einsetzen, und solchen, die er in der Regel vermeiden würde (darunter auch explizite Index-Hints).

Möglicherweise würde ich ein wenig mehr als "a little experience" voraussetzen und auf eine gute Dokumentierung solcher Hints bestehen, aber grundsätzlich sehe ich den Fall ähnlich wie der Herr Kejser.

Keine Kommentare:

Kommentar veröffentlichen