<s>
In	O
computer	B-General_Concept
science	I-General_Concept
,	O
a	O
fractal	B-Data_Structure
tree	I-Data_Structure
index	I-Data_Structure
is	O
a	O
tree	B-Application
data	I-Application
structure	I-Application
that	O
keeps	O
data	O
sorted	O
and	O
allows	O
searches	O
and	O
sequential	O
access	O
in	O
the	O
same	O
time	O
as	O
a	O
B-tree	B-Architecture
but	O
with	O
insertions	O
and	O
deletions	O
that	O
are	O
asymptotically	O
faster	O
than	O
a	O
B-tree	B-Architecture
.	O
</s>
<s>
Like	O
a	O
B-tree	B-Architecture
,	O
a	O
fractal	B-Data_Structure
tree	I-Data_Structure
index	I-Data_Structure
is	O
a	O
generalization	O
of	O
a	O
binary	B-Language
search	I-Language
tree	I-Language
in	O
that	O
a	O
node	O
can	O
have	O
more	O
than	O
two	O
children	O
.	O
</s>
<s>
Furthermore	O
,	O
unlike	O
a	O
B-tree	B-Architecture
,	O
a	O
fractal	B-Data_Structure
tree	I-Data_Structure
index	I-Data_Structure
has	O
buffers	O
at	O
each	O
node	O
,	O
which	O
allow	O
insertions	O
,	O
deletions	O
and	O
other	O
changes	O
to	O
be	O
stored	O
in	O
intermediate	O
locations	O
.	O
</s>
<s>
The	O
goal	O
of	O
the	O
buffers	O
is	O
to	O
schedule	O
disk	O
writes	O
so	O
that	O
each	O
write	O
performs	O
a	O
large	O
amount	O
of	O
useful	O
work	O
,	O
thereby	O
avoiding	O
the	O
worst-case	O
performance	O
of	O
B-trees	B-Architecture
,	O
in	O
which	O
each	O
disk	O
write	O
may	O
change	O
a	O
small	O
amount	O
of	O
data	O
on	O
disk	O
.	O
</s>
<s>
Like	O
a	O
B-tree	B-Architecture
,	O
fractal	B-Data_Structure
tree	I-Data_Structure
indexes	I-Data_Structure
are	O
optimized	O
for	O
systems	O
that	O
read	O
and	O
write	O
large	O
blocks	O
of	O
data	O
.	O
</s>
<s>
The	O
fractal	B-Data_Structure
tree	I-Data_Structure
index	I-Data_Structure
has	O
been	O
commercialized	O
in	O
databases	O
by	O
Tokutek	B-Language
.	O
</s>
<s>
The	O
fractal	B-Data_Structure
tree	I-Data_Structure
index	I-Data_Structure
has	O
also	O
been	O
used	O
in	O
a	O
prototype	O
filesystem	B-Application
.	O
</s>
<s>
An	O
open	B-License
source	I-License
implementation	O
of	O
the	O
fractal	B-Data_Structure
tree	I-Data_Structure
index	I-Data_Structure
is	O
available	O
,	O
which	O
demonstrates	O
the	O
implementation	O
details	O
outlined	O
below	O
.	O
</s>
<s>
In	O
fractal	B-Data_Structure
tree	I-Data_Structure
indexes	I-Data_Structure
,	O
internal	O
(	O
non-leaf	B-Data_Structure
)	O
nodes	O
can	O
have	O
a	O
variable	O
number	O
of	O
child	O
nodes	O
within	O
some	O
pre-defined	O
range	O
.	O
</s>
<s>
Each	O
internal	O
node	O
of	O
a	O
B-tree	B-Architecture
will	O
contain	O
a	O
number	O
of	O
keys	O
that	O
is	O
one	O
less	O
than	O
its	O
branching	B-Data_Structure
factor	I-Data_Structure
.	O
</s>
<s>
The	O
keys	O
act	O
as	O
separation	O
values	O
which	O
divide	O
its	O
subtrees	B-Application
.	O
</s>
<s>
Keys	O
in	O
subtrees	B-Application
are	O
stored	O
in	O
search	B-Data_Structure
tree	I-Data_Structure
order	O
,	O
that	O
is	O
,	O
all	O
keys	O
in	O
a	O
subtree	B-Application
are	O
between	O
the	O
two	O
bracketing	O
values	O
.	O
</s>
<s>
In	O
this	O
regard	O
,	O
they	O
are	O
just	O
like	O
B-trees	B-Architecture
.	O
</s>
<s>
Fractal	B-Data_Structure
tree	I-Data_Structure
indexes	I-Data_Structure
and	O
B-trees	B-Architecture
both	O
exploit	O
the	O
fact	O
that	O
when	O
a	O
node	O
is	O
fetched	O
from	O
storage	O
,	O
a	O
block	O
of	O
memory	O
,	O
whose	O
size	O
is	O
denoted	O
by	O
,	O
is	O
fetched	O
.	O
</s>
<s>
Since	O
access	O
to	O
storage	O
can	O
dominate	O
the	O
running	O
time	O
of	O
a	O
data	O
structure	O
,	O
the	O
time-complexity	O
of	O
external	B-Application
memory	I-Application
algorithms	I-Application
is	O
dominated	O
by	O
the	O
number	O
of	O
read/writes	O
a	O
data	O
structure	O
induces	O
.	O
</s>
<s>
In	O
a	O
B-tree	B-Architecture
,	O
this	O
means	O
that	O
the	O
number	O
of	O
keys	O
in	O
a	O
node	O
is	O
targeted	O
to	O
be	O
enough	O
to	O
fill	O
the	O
node	O
,	O
with	O
some	O
variability	O
for	O
node	O
splits	O
and	O
merges	B-Language
.	O
</s>
<s>
Fractal	O
trees	O
nodes	O
use	O
a	O
smaller	O
branching	B-Data_Structure
factor	I-Data_Structure
,	O
say	O
,	O
of	O
.	O
</s>
<s>
The	O
depth	O
of	O
the	O
tree	O
is	O
then	O
,	O
thereby	O
matching	O
the	O
B-tree	B-Architecture
asymptotically	O
.	O
</s>
<s>
Finally	O
,	O
note	O
that	O
the	O
branching	B-Data_Structure
factor	I-Data_Structure
can	O
vary	O
,	O
but	O
for	O
any	O
branching	B-Data_Structure
factor	I-Data_Structure
,	O
the	O
cost	O
of	O
a	O
flush	O
is	O
,	O
thereby	O
providing	O
a	O
smooth	O
tradeoff	O
between	O
search	O
cost	O
,	O
which	O
depends	O
on	O
the	O
depth	O
of	O
the	O
search	B-Data_Structure
tree	I-Data_Structure
,	O
and	O
therefore	O
the	O
branching	B-Data_Structure
factor	I-Data_Structure
,	O
versus	O
the	O
insertion	O
time	O
,	O
which	O
depends	O
on	O
the	O
depth	O
of	O
the	O
tree	O
but	O
more	O
sensitively	O
on	O
the	O
size	O
of	O
the	O
buffer	O
flushes	O
.	O
</s>
<s>
This	O
section	O
compares	O
fractal	B-Data_Structure
tree	I-Data_Structure
indexes	I-Data_Structure
with	O
other	O
external	O
memory	O
indexing	O
data	O
structures	O
.	O
</s>
<s>
The	O
theoretical	O
literature	O
on	O
this	O
topic	O
is	O
very	O
large	O
,	O
so	O
this	O
discussion	O
is	O
limited	O
to	O
a	O
comparison	O
with	O
popular	O
data	O
structures	O
that	O
are	O
in	O
use	O
in	O
databases	O
and	O
file	B-Application
systems	I-Application
.	O
</s>
<s>
The	O
search	O
time	O
of	O
a	O
B-tree	B-Architecture
is	O
asymptotically	O
the	O
same	O
as	O
that	O
of	O
a	O
fractal	B-Data_Structure
tree	I-Data_Structure
index	I-Data_Structure
.	O
</s>
<s>
However	O
,	O
a	O
fractal	B-Data_Structure
tree	I-Data_Structure
index	I-Data_Structure
has	O
deeper	O
trees	O
than	O
a	O
B-tree	B-Architecture
,	O
and	O
if	O
each	O
node	O
were	O
to	O
require	O
an	O
I/O	O
,	O
say	O
if	O
the	O
cache	O
is	O
cold	O
,	O
then	O
a	O
fractal	B-Data_Structure
tree	I-Data_Structure
index	I-Data_Structure
would	O
induce	O
more	O
IO	O
.	O
</s>
<s>
However	O
,	O
for	O
many	O
workloads	O
most	O
or	O
all	O
internal	O
nodes	O
of	O
both	O
B-trees	B-Architecture
and	O
fractal	B-Data_Structure
tree	I-Data_Structure
indexes	I-Data_Structure
are	O
already	O
cached	O
in	O
RAM	O
.	O
</s>
<s>
Thus	O
,	O
for	O
many	O
workloads	O
,	O
fractal	B-Data_Structure
tree	I-Data_Structure
indexes	I-Data_Structure
can	O
match	O
B-trees	B-Architecture
in	O
terms	O
of	O
search	O
time	O
.	O
</s>
<s>
An	O
insertion	O
in	O
a	O
fractal	B-Data_Structure
tree	I-Data_Structure
index	I-Data_Structure
takes	O
whereas	O
B-trees	B-Architecture
require	O
.	O
</s>
<s>
Thus	O
,	O
fractal	B-Data_Structure
tree	I-Data_Structure
indexes	I-Data_Structure
are	O
faster	O
than	O
B-trees	B-Architecture
by	O
a	O
factor	O
of	O
.	O
</s>
<s>
Both	O
B-trees	B-Architecture
and	O
fractal	B-Data_Structure
tree	I-Data_Structure
indexes	I-Data_Structure
can	O
perform	O
insertions	O
faster	O
in	O
the	O
best	O
case	O
.	O
</s>
<s>
Thus	O
,	O
because	O
the	O
best	O
and	O
worst	O
cases	O
of	O
B-trees	B-Architecture
differ	O
so	O
widely	O
,	O
whereas	O
fractal	B-Data_Structure
tree	I-Data_Structure
indexes	I-Data_Structure
are	O
always	O
near	O
their	O
best	O
case	O
,	O
the	O
actual	O
speedup	O
that	O
fractal	B-Data_Structure
tree	I-Data_Structure
indexes	I-Data_Structure
achieve	O
over	O
B-trees	B-Architecture
depends	O
on	O
the	O
details	O
of	O
the	O
workload	O
.	O
</s>
<s>
Log-structured	B-Data_Structure
merge-trees	I-Data_Structure
(	O
LSMs	O
)	O
refer	O
to	O
a	O
class	O
of	O
data	O
structures	O
which	O
consists	O
of	O
two	O
or	O
more	O
index	O
structures	O
of	O
exponentially	O
growing	O
capacities	O
.	O
</s>
<s>
For	O
comparison	O
purposes	O
,	O
we	O
select	O
the	O
version	O
of	O
LSMs	O
that	O
match	O
fractal	B-Data_Structure
tree	I-Data_Structure
indexes	I-Data_Structure
on	O
insertion	O
performance	O
.	O
</s>
<s>
Suppose	O
an	O
LSM	O
is	O
implemented	O
via	O
B-trees	B-Architecture
,	O
each	O
of	O
which	O
has	O
a	O
capacity	O
that	O
is	O
larger	O
than	O
its	O
predecessor	O
.	O
</s>
<s>
The	O
merge	B-Language
time	O
depends	O
on	O
three	O
facts	O
:	O
The	O
sorted	O
order	O
of	O
keys	O
in	O
an	O
-item	O
B-tree	B-Architecture
can	O
be	O
produced	O
in	O
IOs	O
;	O
Two	O
sorted	O
lists	O
of	O
and	O
items	O
can	O
be	O
merged	O
into	O
a	O
sorted	O
list	O
in	O
IOs	O
;	O
and	O
a	O
B-tree	B-Architecture
of	O
a	O
sorted	O
list	O
of	O
items	O
can	O
be	O
built	O
in	O
IOs	O
.	O
</s>
<s>
When	O
a	O
tree	O
overflows	O
,	O
it	O
is	O
merged	O
into	O
a	O
tree	O
whose	O
size	O
is	O
larger	O
,	O
therefore	O
a	O
level	O
that	O
holds	O
items	O
requires	O
IOs	O
to	O
merge	B-Language
.	O
</s>
<s>
An	O
item	O
may	O
be	O
merged	O
once	O
per	O
level	O
,	O
giving	O
a	O
total	O
time	O
of	O
,	O
which	O
matches	O
the	O
fractal	B-Data_Structure
tree	I-Data_Structure
index	I-Data_Structure
.	O
</s>
<s>
The	O
query	O
time	O
is	O
simply	O
the	O
B-tree	B-Architecture
query	O
time	O
at	O
each	O
level	O
.	O
</s>
<s>
This	O
is	O
larger	O
than	O
both	O
the	O
B-tree	B-Architecture
and	O
fractal	B-Data_Structure
tree	I-Data_Structure
indexes	I-Data_Structure
by	O
a	O
logarithmic	O
factor	O
.	O
</s>
<s>
In	O
fact	O
,	O
although	O
B-trees	B-Architecture
and	O
fractal	B-Data_Structure
tree	I-Data_Structure
indexes	I-Data_Structure
are	O
both	O
on	O
the	O
optimal	O
tradeoff	O
curve	O
between	O
insertions	O
and	O
queries	O
,	O
LSMs	O
are	O
not	O
.	O
</s>
<s>
They	O
are	O
incomparable	O
with	O
B-trees	B-Architecture
and	O
are	O
dominated	O
by	O
fractal	B-Data_Structure
tree	I-Data_Structure
indexes	I-Data_Structure
.	O
</s>
<s>
For	O
example	O
,	O
if	O
only	O
membership	O
queries	O
are	O
required	O
and	O
no	O
successor/predecessor/range	O
queries	O
are	O
,	O
then	O
Bloom	B-Algorithm
filters	I-Algorithm
can	O
be	O
used	O
to	O
speed	O
up	O
queries	O
.	O
</s>
<s>
However	O
,	O
for	O
every	O
choice	O
of	O
insertion	O
rate	O
,	O
the	O
corresponding	O
fractal	B-Data_Structure
tree	I-Data_Structure
index	I-Data_Structure
has	O
faster	O
queries	O
.	O
</s>
<s>
The	O
fractal	B-Data_Structure
tree	I-Data_Structure
index	I-Data_Structure
is	O
a	O
refinement	O
of	O
the	O
Bε	O
tree	O
.	O
</s>
<s>
The	O
fractal	B-Data_Structure
tree	I-Data_Structure
index	I-Data_Structure
differs	O
in	O
including	O
performance	O
optimization	O
and	O
in	O
extending	O
the	O
functionality	O
.	O
</s>
<s>
B-tree	B-Architecture
implementations	O
of	O
ACID	O
semantics	O
typically	O
involve	O
locking	O
rows	O
that	O
are	O
involved	O
in	O
an	O
active	O
transactions	O
.	O
</s>
<s>
Such	O
a	O
scheme	O
works	O
well	O
in	O
a	O
B-tree	B-Architecture
because	O
both	O
insertions	O
and	O
queries	O
involve	O
fetching	O
the	O
same	O
leaf	O
into	O
memory	O
.	O
</s>
<s>
However	O
,	O
in	O
fractal	B-Data_Structure
tree	I-Data_Structure
indexes	I-Data_Structure
,	O
insertions	O
are	O
messages	O
,	O
and	O
a	O
row	O
may	O
reside	O
in	O
more	O
than	O
one	O
node	O
at	O
the	O
same	O
time	O
.	O
</s>
<s>
Fractal	B-Data_Structure
tree	I-Data_Structure
indexes	I-Data_Structure
therefore	O
require	O
a	O
separate	O
locking	O
structure	O
that	O
is	O
IO-efficient	O
or	O
resides	O
in	O
memory	O
in	O
order	O
to	O
implement	O
the	O
locking	O
involved	O
in	O
implementing	O
ACID	O
semantics	O
.	O
</s>
<s>
Fractal	B-Data_Structure
tree	I-Data_Structure
indexes	I-Data_Structure
also	O
have	O
several	O
performance	O
optimizations	O
.	O
</s>
<s>
Second	O
,	O
leaves	O
are	O
much	O
larger	O
than	O
in	O
B-trees	B-Architecture
,	O
which	O
allows	O
for	O
greater	O
compression	O
.	O
</s>
<s>
The	O
solution	O
implemented	O
in	O
fractal	B-Data_Structure
tree	I-Data_Structure
indexes	I-Data_Structure
is	O
to	O
have	O
large	O
leaves	O
that	O
can	O
be	O
fetched	O
as	O
a	O
whole	O
for	O
fast	O
range	O
queries	O
but	O
are	O
broken	O
into	O
smaller	O
pieces	O
call	O
basement	O
nodes	O
which	O
can	O
be	O
fetched	O
individually	O
.	O
</s>
<s>
Thus	O
the	O
substructure	O
of	O
leaves	O
in	O
fractal	B-Data_Structure
tree	I-Data_Structure
indexes	I-Data_Structure
,	O
as	O
compared	O
to	O
Bε	O
trees	O
allows	O
both	O
range	O
and	O
point	O
queries	O
to	O
be	O
fast	O
.	O
</s>
<s>
An	O
upsert	B-Language
is	O
a	O
statement	O
that	O
inserts	O
a	O
row	O
if	O
it	O
does	O
not	O
exist	O
and	O
updates	O
it	O
if	O
it	O
does	O
.	O
</s>
<s>
In	O
a	O
B-tree	B-Architecture
,	O
an	O
upsert	B-Language
is	O
implemented	O
by	O
first	O
searching	O
for	O
the	O
row	O
and	O
then	O
implementing	O
an	O
insertion	O
or	O
an	O
update	O
,	O
depending	O
on	O
the	O
result	O
of	O
the	O
search	O
.	O
</s>
<s>
A	O
fractal	B-Data_Structure
tree	I-Data_Structure
index	I-Data_Structure
can	O
implement	O
an	O
upsert	B-Language
by	O
inserting	O
a	O
special	O
upsert	B-Language
message	O
.	O
</s>
<s>
By	O
avoiding	O
the	O
initial	O
search	O
,	O
upsert	B-Language
messages	O
can	O
improve	O
the	O
speed	O
of	O
upserts	B-Language
by	O
orders	O
of	O
magnitude	O
.	O
</s>
<s>
The	O
fractal	B-Data_Structure
tree	I-Data_Structure
index	I-Data_Structure
has	O
been	O
implemented	O
and	O
commercialized	O
by	O
Tokutek	B-Language
.	O
</s>
<s>
It	O
is	O
available	O
as	O
TokuDB	B-Language
as	O
a	O
storage	O
engine	O
for	O
MySQL	B-Application
and	O
MariaDB	B-Application
,	O
and	O
as	O
TokuMX	O
,	O
a	O
more	O
complete	O
integration	O
with	O
MongoDB	B-Application
.	O
</s>
<s>
Fractal	B-Data_Structure
tree	I-Data_Structure
indexes	I-Data_Structure
have	O
also	O
been	O
used	O
in	O
prototype	O
filesystems	B-Application
,	O
TokuFS	O
and	O
BetrFS	O
.	O
</s>
