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 - SQL Tutorial
From the course: Advanced SQL for Query Tuning and Performance Optimization
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
-
-
-
-
-
-
Types of joins2m 36s
-
(Locked)
Nested loops3m 19s
-
(Locked)
Nested loop example plan3m 59s
-
(Locked)
Hash joins1m 29s
-
(Locked)
Hash join example plan1m 54s
-
(Locked)
Merge joins2m 23s
-
(Locked)
Merge join example3m 2s
-
(Locked)
Subqueries vs. joins1m 13s
-
(Locked)
Challenge: Designing a join24s
-
(Locked)
Solution: Designing a join22s
-
-
-
-
-
-