Using Hints
In some cases, you might think that there is a better way to execute your queries than the query plan selected by the Query Optimizer. SQL Server 2000 provides several optimizer hints to tailor the execution to your needs.
You can specify the type of join to execute by using the LOOP, HASH, MERGE, or REMOTE hints of the JOIN clause. The query in Listing 11.23 forces a LOOP join to connect the Orders and Order Details tables, a MERGE join between the Products and Order Details table, and a HASH join to connect the Categories and Products tables. The purpose of this example is to show how to use the optimizer hints; the output is the same you can have without using these optimizer hints.
Note
Joins were covered in Chapter 5. The REMOTE ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access