Block Nested Loop

A block-nested loop (BNL) 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 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. 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.

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.

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.

Famous quotes containing the words block and/or nested:

    Painting consumes labour not disproportionate to its effect; but a fellow will hack half a year at a block of marble to make something in stone that hardly resembles a man. The value of statuary is owing to its difficulty. You would not value the finest head cut upon a carrot.
    Samuel Johnson (1709–1784)

    I was asking for something specific and perfect for my city,
    Whereupon lo! upsprang the aboriginal name.
    Now I see what there is in a name, a word, liquid, sane, unruly,
    musical, self-sufficient,
    I see that the word of my city is that word from of old,
    Because I see that word nested in nests of water-bays, superb,
    Rich, hemm’d thick all around with sailships and steamships, an
    island sixteen miles long, solid-founded,
    Walt Whitman (1819–1892)