Block nested loop

Block nested loop

A block-nested loop is an algorithm used to join two relations in a relational database.

This algorithm is a variation on the simple nested loop join used to join two relations R and S (the "outer" and "inner" join operands, respectively). Suppose |R| < |S|. In a traditional nested loop join, S will be scanned once for every tuple of R. If there are many qualifying R tuples, and particularly if there is no applicable index for the join key on S, this operation will be very expensive.

The block nested loop join algorithm improves on the simple nested loop join by only scanning S once for every "group" of R tuples. For example, one variant of the block nested loop join reads an entire page of R tuples into memory and loads them into a hash table. It then scans S, and probes the hash table to find S tuples that match any of the tuples in the current page of R. This reduces the number of scans of S that are necessary.

A more aggressive variant of this algorithm loads as many pages of R as can be fit in the available memory, loading all such tuples into a hash table, and then repeatedly scans S. This further reduces the number of scans of S that are necessary. In fact, this algorithm is essentially a special-case of the classic hash join algorithm.

The block nested loop runs in O(P_r P_s/M) I/Os where M is the number of available pages of internal memory and P_r and P_s is size of R and S respectively in pages. Notethat block nested loop runs in O(P_r+P_s) I/Os if R fits in the available internal memory.


Wikimedia Foundation. 2010.

Игры ⚽ Поможем сделать НИР

Look at other dictionaries:

  • Nested loop join — A nested loop join is a naive algorithm that joins two relations R and S by making two nested loops: For each tuple r in R do For each tuple s in S do If r and s satisfy the join condition Then output the tuple <r,s> This algorithm will… …   Wikipedia

  • Nested Loop — Der Nested Loop Join ist eine mögliche Strategie in einem Datenbanksystem für Umsetzungen von Joins. Dabei werden nacheinander alle Tupel (Informatik) aus der einen Relation ausgewählt und mit jedem Tupel aus der anderen verglichen. Beispiel Für… …   Deutsch Wikipedia

  • Nested Loop Join — Der Nested Loop Join ist eine mögliche Strategie in einem Datenbanksystem für Umsetzungen von Joins. Dabei werden nacheinander alle Tupel (Informatik) aus der einen Relation ausgewählt und mit jedem Tupel aus der anderen verglichen. Beispiel Für… …   Deutsch Wikipedia

  • Loop nest optimization — (LNO) is a special case of loop transformation, dealing with nested loops, that allows large reductions in the cache bandwidth necessary for some common algorithms.Example: Matrix multiplyMany large mathematical operations on computers end up… …   Wikipedia

  • For loop — In computer science a for loop is a programming language statement which allows code to be repeatedly executed. A for loop is classified as an iteration statement.Unlike many other kinds of loops, such as the while loop, the for loop is often… …   Wikipedia

  • Stem-loop — intramolecular base pairing is a pattern that can occur in single stranded DNA or, more commonly, in RNA. The structure is also known as a hairpin or hairpin loop. It occurs when two regions of the same molecule, usually palindromic (reads the… …   Wikipedia

  • Joinalgorithmen — sind mögliche Strategien (Algorithmen) zur Implementierung von Joins. Die optimale Strategie hängt von Größe und Struktur der am Join beteiligten Relationen, verwendeten oder verwendbaren Indizes, der Größe des Hauptspeichers als auch der Join… …   Deutsch Wikipedia

  • Hash join — The Hash join is an example of a join algorithm and is used in the implementation of a relational database management system.The task of a join algorithm is to find, for each distinct value of the join attribute, the set of tuples in each… …   Wikipedia

  • Control flow — Not to be confused with Flow control. In computer science, control flow (or alternatively, flow of control) refers to the order in which the individual statements, instructions, or function calls of an imperative or a declarative program are… …   Wikipedia

  • Perl control structures — The basic control structures of Perl are similar to those used in C and Java, but they have been extended in several ways.LoopsIn the following, label is an optional identifier terminated by a colon, and block is a sequence of one of more Perl… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”