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 ...

Get Microsoft® SQL Server™ 2000 Programming by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.