From the course: Advanced SQL for Query Tuning and Performance Optimization

Unlock the full course today

Join today to access over 24,400 courses taught by industry experts.

Nested loops

Nested loops

- [Instructor] Now let's look at how execution plans map declarative joins into procedural operations. We'll start with nested loop joins. Nested loops are a naive approach to joining tables, but their big advantage is that they will work with any kind of join, using either equality, inequality, or range operators. As the name implies, a nested loop join works by running two loops, one within the other. The outer loop iterates over one table called the driver table. The inner loop iterates over the other table called the join table. The outer loop executes once, and the inner loop runs once for each row in the join table. Let's look at an example. Here we want to join some data about customers and their status level, which indicates how much revenue the customer generates. Now, the status level is a foreign key in the customer table and the primary key in the status table. The customer table is the driver table, and…

Contents