<s>
A	O
block-nested	B-Algorithm
loop	I-Algorithm
(	O
BNL	O
)	O
is	O
an	O
algorithm	O
used	O
to	O
join	B-Language
two	O
relations	B-Language
in	O
a	O
relational	B-Application
database	I-Application
.	O
</s>
<s>
This	O
algorithm	O
is	O
a	O
variation	O
of	O
the	O
simple	O
nested	B-Algorithm
loop	I-Algorithm
join	I-Algorithm
and	O
joins	O
two	O
relations	B-Language
and	O
(	O
the	O
"	O
outer	O
"	O
and	O
"	O
inner	O
"	O
join	B-Language
operands	O
,	O
respectively	O
)	O
.	O
</s>
<s>
In	O
a	O
traditional	O
nested	B-Algorithm
loop	I-Algorithm
join	I-Algorithm
,	O
will	O
be	O
scanned	O
once	O
for	O
every	O
tuple	B-Application
of	O
.	O
</s>
<s>
If	O
there	O
are	O
many	O
qualifying	O
tuples	B-Application
,	O
and	O
particularly	O
if	O
there	O
is	O
no	O
applicable	O
index	B-Data_Structure
for	O
the	O
join	B-Language
key	O
on	O
,	O
this	O
operation	O
will	O
be	O
very	O
expensive	O
.	O
</s>
<s>
The	O
block	B-Algorithm
nested	I-Algorithm
loop	I-Algorithm
join	I-Algorithm
algorithm	O
improves	O
on	O
the	O
simple	O
nested	B-Algorithm
loop	I-Algorithm
join	I-Algorithm
by	O
only	O
scanning	O
once	O
for	O
every	O
group	O
of	O
tuples	B-Application
.	O
</s>
<s>
Here	O
groups	O
are	O
disjoint	B-Algorithm
sets	I-Algorithm
of	O
tuples	B-Application
in	O
and	O
the	O
union	O
of	O
all	O
groups	O
has	O
the	O
same	O
tuples	B-Application
as	O
.	O
</s>
<s>
For	O
example	O
,	O
one	O
variant	O
of	O
the	O
block	B-Algorithm
nested	I-Algorithm
loop	I-Algorithm
join	B-Language
reads	O
an	O
entire	O
page	B-General_Concept
of	O
tuples	B-Application
into	O
memory	B-General_Concept
and	O
loads	O
them	O
into	O
a	O
hash	B-Algorithm
table	I-Algorithm
.	O
</s>
<s>
It	O
then	O
scans	O
,	O
and	O
probes	O
the	O
hash	B-Algorithm
table	I-Algorithm
to	O
find	O
tuples	B-Application
that	O
match	O
any	O
of	O
the	O
tuples	B-Application
in	O
the	O
current	O
page	B-General_Concept
of	O
.	O
</s>
<s>
A	O
more	O
aggressive	O
variant	O
of	O
this	O
algorithm	O
loads	O
as	O
many	O
pages	O
of	O
as	O
can	O
be	O
fit	O
in	O
the	O
available	O
memory	B-General_Concept
,	O
loading	O
all	O
such	O
tuples	B-Application
into	O
a	O
hash	B-Algorithm
table	I-Algorithm
,	O
and	O
then	O
repeatedly	O
scans	O
.	O
</s>
<s>
In	O
fact	O
,	O
this	O
algorithm	O
is	O
essentially	O
a	O
special-case	O
of	O
the	O
classic	O
hash	B-Algorithm
join	I-Algorithm
algorithm	O
.	O
</s>
<s>
The	O
block	B-Algorithm
nested	I-Algorithm
loop	I-Algorithm
runs	O
in	O
I/Os	O
where	O
is	O
the	O
number	O
of	O
available	O
pages	O
of	O
internal	O
memory	B-General_Concept
and	O
and	O
is	O
size	O
of	O
and	O
respectively	O
in	O
pages	O
.	O
</s>
<s>
that	O
block	B-Algorithm
nested	I-Algorithm
loop	I-Algorithm
runs	O
in	O
I/Os	O
if	O
fits	O
in	O
the	O
available	O
internal	O
memory	B-General_Concept
.	O
</s>
