Call now: (800) 766-1884  


 SQL Server Tips
 SQL Server Training

 SQL Server Consulting
 SQL Server Support
 SQL Server Remote DBA

 SQL Server Scripts
 Scripts Menu




  SQL Server Tips by Robin Schumacher

Nasty Join Operations

There are several join operations that should be avoided in a query. Leading the pack is the Cartesian join. It normally appears only as a coding mistake on the part of the user who issued the query. A Cartesian join means there are two tables involved in a query that have not been properly joined together through some relational column pairing. For example:

admission a,
patient b
patient_last_name like 'JUNG%'

The two tables in the above query have not been paired together through a common relational column that is present in both tables; therefore, SQL Server will have to utilize a Cartesian join. The Cartesian join multiplies the number of rows in the first table by the number of rows in the second table to arrive at the result set.

To guard against Cartesian joins, the standard rule of thumb is there must be (N 1) number of join predicates, where N represents the number of tables in the FROM clause. A Cartesian product can be spotted easily in the EXPLAIN as there will be a larger signaled result set than expected.

Besides Cartesian joins, be on the lookout for other join operations that can contribute to excessive run times. The most common heavy-duty joins are hash and merge joins. These joins perform more in-memory processing than nested loop joins, and therefore, the DBA will see higher CPU and memory usage from these operations.

Often, indexing changes can transform the hash join into a nested loop join. Since each situation is different, keep a close eye on the performance execution metrics as different combinations are tried.

The above book excerpt is from:

High-Performance SQL Server DBA
Tuning & Optimization Secrets

ISBN: 0-9761573-6-5
Robin Schumacher  


Burleson Consulting Remote DB Administration







Burleson is the America's Team

Note: The pages on this site were created as a support and training reference for use by our staff of DBA consultants.  If you find it confusing, please exit this page.

Errata?  SQL Server technology is changing and we strive to update our SQL Server support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:and include the URL for the page.

Burleson Consulting
SQL Server database support


Copyright 1996 -  2013 by Vaaltech Web Services. All rights reserved.

Hit Counter