<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://debianws.lexgopc.com/wiki143/index.php?action=history&amp;feed=atom&amp;title=Block_nested_loop</id>
	<title>Block nested loop - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://debianws.lexgopc.com/wiki143/index.php?action=history&amp;feed=atom&amp;title=Block_nested_loop"/>
	<link rel="alternate" type="text/html" href="http://debianws.lexgopc.com/wiki143/index.php?title=Block_nested_loop&amp;action=history"/>
	<updated>2026-10-25T21:26:42Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.1</generator>
	<entry>
		<id>http://debianws.lexgopc.com/wiki143/index.php?title=Block_nested_loop&amp;diff=3756882&amp;oldid=prev</id>
		<title>imported&gt;Ponyo: mass addition of incorrect grammar changes</title>
		<link rel="alternate" type="text/html" href="http://debianws.lexgopc.com/wiki143/index.php?title=Block_nested_loop&amp;diff=3756882&amp;oldid=prev"/>
		<updated>2023-11-29T21:25:04Z</updated>

		<summary type="html">&lt;p&gt;mass addition of incorrect grammar changes&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{short description|Algorithm}}&lt;br /&gt;
A &amp;#039;&amp;#039;&amp;#039;block-nested loop&amp;#039;&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;BNL&amp;#039;&amp;#039;&amp;#039;) is an [[algorithm]] used to [[join (SQL)|join]] two relations in a [[relational database]].&amp;lt;ref name=mysql&amp;gt;{{cite web|title=8.2.1.14 Block Nested-Loop and Batched Key Access Joins|url=http://dev.mysql.com/doc/refman/5.6/en/bnl-bka-optimization.html|website=MySQL 5.6 Reference Manual|publisher=Oracle Corporation|accessdate=2 August 2015}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This algorithm&amp;lt;ref name=MariaDB&amp;gt;{{cite web|title=Block Nested Loop Join|url=https://mariadb.com/kb/en/mariadb/block-based-join-algorithms/|website=MariaDB|publisher=MariaDB Corporation Ab|accessdate=2 August 2015}}&amp;lt;/ref&amp;gt; is a variation of the simple [[nested loop join]] and joins two [[Relation (database)|relations]] &amp;lt;math&amp;gt;R&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; (the &amp;quot;outer&amp;quot; and &amp;quot;inner&amp;quot; join operands, respectively). Suppose &amp;lt;math&amp;gt;|R| &amp;lt; |S|&amp;lt;/math&amp;gt;. In a traditional nested loop join, &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; will be scanned once for every [[tuple]] of &amp;lt;math&amp;gt;R&amp;lt;/math&amp;gt;. If there are many qualifying &amp;lt;math&amp;gt;R&amp;lt;/math&amp;gt; tuples, and particularly if there is no applicable [[Database index|index]] for the join key on &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt;, this operation will be very expensive.&lt;br /&gt;
&lt;br /&gt;
The block nested loop join algorithm improves on the simple nested loop join by only scanning &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; once for every &amp;#039;&amp;#039;group&amp;#039;&amp;#039; of &amp;lt;math&amp;gt;R&amp;lt;/math&amp;gt; tuples. Here groups are [[disjoint sets]] of tuples in &amp;lt;math&amp;gt;R&amp;lt;/math&amp;gt; and the [[Union (set theory)|union]] of all groups has the same tuples as &amp;lt;math&amp;gt;R&amp;lt;/math&amp;gt;. For example, one variant of the block nested loop join reads an entire [[page (computing)|page]] of &amp;lt;math&amp;gt;R&amp;lt;/math&amp;gt; tuples into [[Computer memory|memory]] and loads them into a [[hash table]]. It then scans &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt;, and probes the hash table to find &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; tuples that match any of the tuples in the current page of &amp;lt;math&amp;gt;R&amp;lt;/math&amp;gt;. This reduces the number of scans of &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; that are necessary.&lt;br /&gt;
&lt;br /&gt;
 &amp;#039;&amp;#039;&amp;#039;algorithm&amp;#039;&amp;#039;&amp;#039; block_nested_loop_join &amp;#039;&amp;#039;&amp;#039;is&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
     &amp;#039;&amp;#039;&amp;#039;for each&amp;#039;&amp;#039;&amp;#039; page &amp;#039;&amp;#039;pr&amp;#039;&amp;#039; in &amp;#039;&amp;#039;R&amp;#039;&amp;#039; &amp;#039;&amp;#039;&amp;#039;do&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
         &amp;#039;&amp;#039;&amp;#039;for each&amp;#039;&amp;#039;&amp;#039; page &amp;#039;&amp;#039;ps&amp;#039;&amp;#039; in &amp;#039;&amp;#039;S&amp;#039;&amp;#039; &amp;#039;&amp;#039;&amp;#039;do&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
             &amp;#039;&amp;#039;&amp;#039;for each&amp;#039;&amp;#039;&amp;#039; tuple &amp;#039;&amp;#039;r&amp;#039;&amp;#039; in &amp;#039;&amp;#039;pr&amp;#039;&amp;#039; &amp;#039;&amp;#039;&amp;#039;do&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
                 &amp;#039;&amp;#039;&amp;#039;for each&amp;#039;&amp;#039;&amp;#039; tuple &amp;#039;&amp;#039;s&amp;#039;&amp;#039; in &amp;#039;&amp;#039;ps&amp;#039;&amp;#039; &amp;#039;&amp;#039;&amp;#039;do&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
                     &amp;#039;&amp;#039;&amp;#039;if&amp;#039;&amp;#039;&amp;#039; &amp;#039;&amp;#039;r&amp;#039;&amp;#039; and &amp;#039;&amp;#039;s&amp;#039;&amp;#039; satisfy the join condition &amp;#039;&amp;#039;&amp;#039;then&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
                         &amp;#039;&amp;#039;&amp;#039;yield&amp;#039;&amp;#039;&amp;#039; tuple &amp;lt;&amp;#039;&amp;#039;r&amp;#039;&amp;#039;,&amp;#039;&amp;#039;s&amp;#039;&amp;#039;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A more aggressive variant of this algorithm loads as many pages of &amp;lt;math&amp;gt;R&amp;lt;/math&amp;gt; as can be fit in the available memory, loading all such tuples into a hash table, and then repeatedly scans &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt;. This further reduces the number of scans of &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; that are necessary. In fact, this algorithm is essentially a special-case of the classic [[hash join]] algorithm.{{citation-needed|date=August 2015}}&lt;br /&gt;
&lt;br /&gt;
The block nested loop runs in &amp;lt;math&amp;gt;O(P_r P_s/M)&amp;lt;/math&amp;gt; I/Os where &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt; is the number of available pages of internal memory and &amp;lt;math&amp;gt;P_r&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;P_s&amp;lt;/math&amp;gt; is size of &amp;lt;math&amp;gt;R&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; respectively in pages. Note&lt;br /&gt;
that block nested loop runs in &amp;lt;math&amp;gt;O(P_r+P_s)&amp;lt;/math&amp;gt; I/Os if &amp;lt;math&amp;gt;R&amp;lt;/math&amp;gt; fits in the available internal memory.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
{{Reflist}}&lt;br /&gt;
&lt;br /&gt;
{{DEFAULTSORT:Block Nested Loop}}&lt;br /&gt;
[[Category:Join algorithms]]&lt;/div&gt;</summary>
		<author><name>imported&gt;Ponyo</name></author>
	</entry>
</feed>