17.07.2015 Views

SQL Server Execution Plans - Grant Fritchey - SQLServerCentral.com

SQL Server Execution Plans - Grant Fritchey - SQLServerCentral.com

SQL Server Execution Plans - Grant Fritchey - SQLServerCentral.com

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 5: Controlling <strong>Execution</strong> <strong>Plans</strong>with HintsIt is possible, using various available hints, to impose your will on the optimizer and, tosome degree, control its behavior. There are three categories of hints, which include:• Query hints tell the optimizer to apply a hint throughout the execution of theentire query.• Join hints tell the optimizer to use a particular join at a particular point in the query.• Table hints control Table Scans and the use of a particular index for a table.In this chapter, I'll describe how to use each type of hint, but I can't stress the followingenough: hints are dangerous. Hints detract from the optimizer's ability to make choices.Appropriate use of the right hint on the right query can improve query performance. Theexact same hint used on another query can create more problems than it solves, radicallyslowing your query and leading to severe blocking and timeouts in your application.If you find yourself putting hints on a majority of your queries and stored procedures,then you're doing something wrong. As part of describing what the hints do, I'll lay outthe problem that you're hoping to solve by applying that hint. Some of the exampleswill improve performance or change the behavior in a positive manner, and some willnegatively affect performance.177

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!