Synonyms
Definition
The nested loop join is a common join algorithm in database systems using two nested loops. The algorithm starts with reading the outer relation R, and for each tuple \({\cal R}\in R\), the inner relation S is checked and matching tuples are added to the result.
Algorithm 1: Nested Loop Join: R⋈ pred(r, s) S |
foreach R ∈ R do |
foreach S ∈ S do |
if pred (R.r, S.s) then |
add {R, S} to result |
end |
end |
end |
Key Points
One advantage of the nested loop join is that it can handle any kind of join predicates, unlike the sort-merge join and the hash join which mainly deal with an equality join predicate. An improvement over the simple nested loop join is the block nested loop join which effectively utilizes buffer pages and reduces disk I/Os.
Block Nested Loop Join
Suppose that the memory can hold B buffer pages. If there is enough memory to hold the smaller relation, say R, with at least two extra buffer pages left, the optimal approach is to read in...
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Recommended Reading
Mishra P. and Eich M.H. Join processing in relational databases. ACM Comput. Surv., 24(1):63–113, 1992.
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2009 Springer Science+Business Media, LLC
About this entry
Cite this entry
Zhou, J. (2009). Nested Loop Join. In: LIU, L., ÖZSU, M.T. (eds) Encyclopedia of Database Systems. Springer, Boston, MA. https://doi.org/10.1007/978-0-387-39940-9_868
Download citation
DOI: https://doi.org/10.1007/978-0-387-39940-9_868
Publisher Name: Springer, Boston, MA
Print ISBN: 978-0-387-35544-3
Online ISBN: 978-0-387-39940-9
eBook Packages: Computer ScienceReference Module Computer Science and Engineering