A block-nested loop (BNL) is an algorithm used to join two relations in a relational database.[1]

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

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

algorithm block_nested_loop_join is
    for each page pr in R do
        for each page ps in S do
            for each tuple r in pr do
                for each tuple s in ps do
                    if r and s satisfy the join condition then
                        yield tuple <r,s>


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

The block nested loop runs in I/Os where is the number of available pages of internal memory and and is size of and respectively in pages. Note that block nested loop runs in I/Os if fits in the available internal memory.

References

edit
  1. ^ "8.2.1.14 Block Nested-Loop and Batched Key Access Joins". MySQL 5.6 Reference Manual. Oracle Corporation. Retrieved 2 August 2015.
  2. ^ "Block Nested Loop Join". MariaDB. MariaDB Corporation Ab. Retrieved 2 August 2015.

📚 Artikel Terkait di Wikipedia

Nested loop join

A nested loop join is a naive algorithm that joins two relations by using two nested loops. Join operations are important for database management. Two

BNL

train station in Normal, Illinois, USA; Amtrak station code BNL Block nested loop, an algorithm in computing This disambiguation page lists articles

Control flow

Retrieved 2016-06-01. "Nested Loops in C with Examples". GeeksforGeeks. 2019-11-25. Retrieved 2024-03-14. "Python Nested Loops". www.w3schools.com. Retrieved

Loop nest optimization

parallelization or another loop overhead reduction of the loop nests. (Nested loops occur when one loop is inside of another loop.) One classical usage is

Loop (statement)

continue outer_loop end if repeat repeat (This nested loop displays the pairs (1, 1), (1, 2), and (2, 1)) An infinite loop is a loop which never terminates

Hash join

tuples to the output relation This is essentially the same as the block nested loop join algorithm. This algorithm may scan S {\displaystyle S} more times

Nested function

programming, a nested function (or nested procedure or subroutine) is a named function that is defined within another (enclosing) block and is lexically

Inner loop

loop which causes a block of code to be executed more than once. A common idiom is to have a loop nested inside another loop, with the contained loop