57
Fractal Tree ® Technology Overview The Art of Indexing Martín Farach-Colton Co-founder & Chief Technology Officer

Fractal tree-technology-and-the-art-of-indexing

Embed Size (px)

Citation preview

Page 1: Fractal tree-technology-and-the-art-of-indexing

Fractal Tree® Technology OverviewThe Art of Indexing

Martín Farach-ColtonCo-founder & Chief Technology Officer

Page 2: Fractal tree-technology-and-the-art-of-indexing

The Art of Indexing®

Not all indexing is the same

B-tree is the basis for almost all DB systems• Data structure invented in 1972

• Has not kept up with hardware trends‣ Works poorly on modern rotational disks‣ Works poorly on SSD

Fractal Tree Indexes is the basis of TokuDB• Scales with hardware

• Fast Indexing ➔ More Indexing ➔ Faster Queries

• Great Compression

• No Fragmentation

• Reduced wear on SSDs

Page 3: Fractal tree-technology-and-the-art-of-indexing

How do Fractal Tree Indexes outperform

B-trees?

Page 4: Fractal tree-technology-and-the-art-of-indexing

How do Fractal Tree Indexes outperform

B-trees?

First, some facts about storage systems

Page 5: Fractal tree-technology-and-the-art-of-indexing

The Art of Indexing®

Storage is quirky

Hard disks are slow for random I/O but fast for

sequential I/O

Difference causes problems like fragmentation, ...

Page 6: Fractal tree-technology-and-the-art-of-indexing

The Art of Indexing®

Storage is quirky

Hard disks are slow for random I/O but fast for

sequential I/O

SSDs are fast for random I/O but expensive for

sequential.

Garbage collection causes artefacts: increased

wear, write cliffs...

Difference causes problems like fragmentation, ...

Page 7: Fractal tree-technology-and-the-art-of-indexing

The Art of Indexing®

Storage ♡ Big Reads and Writes

Big I/Os

Page 8: Fractal tree-technology-and-the-art-of-indexing

The Art of Indexing®

Storage ♡ Big Reads and Writes

Big I/Os

Hard Disks: No Fragmentation

Page 9: Fractal tree-technology-and-the-art-of-indexing

The Art of Indexing®

Storage ♡ Big Reads and Writes

Big I/Os

Hard Disks: No Fragmentation SSDs: Less Garbage

Collection & Wear

Page 10: Fractal tree-technology-and-the-art-of-indexing

The Art of Indexing®

Storage ♡ Big Reads and Writes

Big I/Os

Hard Disks: No Fragmentation SSDs: Less Garbage

Collection & Wear

But you only get the goodies if each I/O has lots of new bytes

Page 11: Fractal tree-technology-and-the-art-of-indexing

The Art of Indexing®

Storage ♡ Big Reads and Writes

Big I/Os

Hard Disks: No Fragmentation SSDs: Less Garbage

Collection & Wear

But you only get the goodies if each I/O has lots of new bytes

If you read a big block, change one byte, then write it, you get terrible wear problems

Page 12: Fractal tree-technology-and-the-art-of-indexing

The Art of Indexing®

Storage ♡ Big Reads and Writes

Big I/Os

Hard Disks: No Fragmentation SSDs: Less Garbage

Collection & Wear

Both: Better Compression

But you only get the goodies if each I/O has lots of new bytes

If you read a big block, change one byte, then write it, you get terrible wear problems

Page 13: Fractal tree-technology-and-the-art-of-indexing

The Art of Indexing®

Caching is great• But you can’t cache all your data

• For stuff not in memory, you have to go to disk

Goal: Do the best we can for the stuff on disk

Data is big, RAM is Small

Data

RAM

Page 14: Fractal tree-technology-and-the-art-of-indexing

Now, What’s a B-tree? & a Fractal Tree Index

Page 15: Fractal tree-technology-and-the-art-of-indexing

The Art of Indexing®

What’s a B-tree?

B

B B B... ...

B B……………………………………………….………….

Search Tree

Page 16: Fractal tree-technology-and-the-art-of-indexing

The Art of Indexing®

What’s a B-tree?

B

B B B... ...

B B……………………………………………….………….

Each node has B pivots

Search Tree

Page 17: Fractal tree-technology-and-the-art-of-indexing

The Art of Indexing®

What’s a B-tree?

B

B B B... ...

B B……………………………………………….………….

Each node has B pivots

Search Tree

Fetching pivots as a group saves I/Os

Page 18: Fractal tree-technology-and-the-art-of-indexing

The Art of Indexing®

What’s a B-tree?

B

B B B... ...

B B……………………………………………….………….

Each node has B pivots

Search Tree

Fetching pivots as a group saves I/Os

Most leaves are on disk, not in RAM

Page 19: Fractal tree-technology-and-the-art-of-indexing

The Art of Indexing®

What’s a B-tree?

B

B B B... ...

B B……………………………………………….………….

Each node has B pivots

Search Tree

Fetching pivots as a group saves I/Os

Most leaves are on disk, not in RAM Inserting into a leaf that’s not in memory will require an I/O per insertion

Page 20: Fractal tree-technology-and-the-art-of-indexing

The Art of Indexing®

B-tree Delivery Service

If fast memory is like walking across a room• Each update in a B-tree is a walking trip from ‣ New York

Page 21: Fractal tree-technology-and-the-art-of-indexing

The Art of Indexing®

B-tree Delivery Service

If fast memory is like walking across a room• Each update in a B-tree is a walking trip from ‣ New York to St Louis

Page 22: Fractal tree-technology-and-the-art-of-indexing

The Art of Indexing®

B-tree Delivery Service

If fast memory is like walking across a room• Each update in a B-tree is a walking trip from ‣ New York to St Louis

Each item gets its own round trip!

Page 23: Fractal tree-technology-and-the-art-of-indexing

The Art of Indexing®

Real-world delivery

Keep regional warehouses• Only move stuff when you can move a lot

Page 24: Fractal tree-technology-and-the-art-of-indexing

The Art of Indexing®

Real-world delivery

Keep regional warehouses• Only move stuff when you can move a lot

Each item gets moved several times

Page 25: Fractal tree-technology-and-the-art-of-indexing

The Art of Indexing®

Real-world delivery

Keep regional warehouses• Only move stuff when you can move a lot

Each item gets moved several times

But each trip is vastly cheaper

Page 26: Fractal tree-technology-and-the-art-of-indexing

The Art of Indexing®

Fractal Tree Indexes

B

B B BB

Each node has pivots & Buffers

Page 27: Fractal tree-technology-and-the-art-of-indexing

The Art of Indexing®

Fractal Tree Indexes

B

B B BB

Each node has pivots & Buffers

Page 28: Fractal tree-technology-and-the-art-of-indexing

The Art of Indexing®

Fractal Tree Indexes

B

B B BB

Each node has pivots & Buffers

Page 29: Fractal tree-technology-and-the-art-of-indexing

The Art of Indexing®

Fractal Tree Indexes

B

B B BB

Each node has pivots & Buffers

Buffers fill as updates arrive

Page 30: Fractal tree-technology-and-the-art-of-indexing

The Art of Indexing®

Fractal Tree Indexes

B

B B BB

Each node has pivots & Buffers

Buffers fill as updates arrive

Page 31: Fractal tree-technology-and-the-art-of-indexing

The Art of Indexing®

Fractal Tree Indexes

B

B B BB

Each node has pivots & Buffers

Buffers fill as updates arrive

Page 32: Fractal tree-technology-and-the-art-of-indexing

The Art of Indexing®

Fractal Tree Indexes

B

B B BB

Each node has pivots & Buffers

Buffers fill as updates arrive

Page 33: Fractal tree-technology-and-the-art-of-indexing

The Art of Indexing®

Fractal Tree Indexes

B

B B BB

Each node has pivots & Buffers

Buffers fill as updates arrive

Page 34: Fractal tree-technology-and-the-art-of-indexing

The Art of Indexing®

Fractal Tree Indexes

B

B B BB

Each node has pivots & Buffers

Buffers fill as updates arrive

Page 35: Fractal tree-technology-and-the-art-of-indexing

The Art of Indexing®

Fractal Tree Indexes

B

B B BB

Each node has pivots & Buffers

Buffers fill as updates arrive

Page 36: Fractal tree-technology-and-the-art-of-indexing

The Art of Indexing®

Fractal Tree Indexes

B

B B BB

Each node has pivots & Buffers

Buffers fill as updates arrive

Page 37: Fractal tree-technology-and-the-art-of-indexing

The Art of Indexing®

Fractal Tree Indexes

B

B B BB

Each node has pivots & Buffers

Buffers fill as updates arrive

Page 38: Fractal tree-technology-and-the-art-of-indexing

The Art of Indexing®

Fractal Tree Indexes

B

B B BB

Each node has pivots & Buffers

Buffers fill as updates arrive

Page 39: Fractal tree-technology-and-the-art-of-indexing

The Art of Indexing®

Fractal Tree Indexes

B

B B BB

Each node has pivots & Buffers

Buffers fill as updates arrive

Page 40: Fractal tree-technology-and-the-art-of-indexing

The Art of Indexing®

Fractal Tree Indexes

B

B B BB

Each node has pivots & Buffers

Buffers fill as updates arrive

Page 41: Fractal tree-technology-and-the-art-of-indexing

The Art of Indexing®

Fractal Tree Indexes

B

B B BB

Each node has pivots & Buffers

Buffers fill as updates arrive

Page 42: Fractal tree-technology-and-the-art-of-indexing

The Art of Indexing®

Fractal Tree Indexes

B

B B BB

Each node has pivots & Buffers

Buffers fill as updates arrive

Page 43: Fractal tree-technology-and-the-art-of-indexing

The Art of Indexing®

Fractal Tree Indexes

B

B B BB

Each node has pivots & Buffers

Buffers fill as updates arrive

Page 44: Fractal tree-technology-and-the-art-of-indexing

The Art of Indexing®

Fractal Tree Indexes

B

B B BB

Each node has pivots & Buffers

Buffers fill as updates arrive

Page 45: Fractal tree-technology-and-the-art-of-indexing

The Art of Indexing®

Fractal Tree Indexes

B

B B BB

Each node has pivots & Buffers

Buffers fill as updates arrive

Flush a buffer when it fills

Page 46: Fractal tree-technology-and-the-art-of-indexing

The Art of Indexing®

Fractal Tree Indexes

B

B B BB

Each node has pivots & Buffers

Buffers fill as updates arrive

Flush a buffer when it fills

A flush might take an I/O, but it does lots of useful work

Page 47: Fractal tree-technology-and-the-art-of-indexing

The Art of Indexing®

Fractal Tree Indexes

B

B B BB

Each node has pivots & Buffers

Buffers fill as updates arrive

Flush a buffer when it fills

A flush might take an I/O, but it does lots of useful work

More changes per write ➔ fewer changes for same write

load ➔ less SSD wear

Page 48: Fractal tree-technology-and-the-art-of-indexing

The Art of Indexing®

Fractal Tree Indexes: Queries

B

B B BB

Lots of buffers have messages

Page 49: Fractal tree-technology-and-the-art-of-indexing

The Art of Indexing®

Fractal Tree Indexes: Queries

B

B B BB

Lots of buffers have messages

But query follows root-leaf path

Page 50: Fractal tree-technology-and-the-art-of-indexing

The Art of Indexing®

Fractal Tree Indexes: Queries

B

B B BB

Lots of buffers have messages

But query follows root-leaf path

So every query has the most up-to-date information

Page 51: Fractal tree-technology-and-the-art-of-indexing

The Art of Indexing®

Fractal Tree Indexes: Queries

B

B B BB

Lots of buffers have messages

But query follows root-leaf path

So every query has the most up-to-date information

Messages can be insert, update, delete

Page 52: Fractal tree-technology-and-the-art-of-indexing

The Art of Indexing®

Fractal Tree Indexes: Schema Changes

B

B B BB

Schema Changes are broadcast messages

Page 53: Fractal tree-technology-and-the-art-of-indexing

The Art of Indexing®

Fractal Tree Indexes: Schema Changes

B

B B BB

Schema Changes are broadcast messages

Page 54: Fractal tree-technology-and-the-art-of-indexing

The Art of Indexing®

Fractal Tree Indexes: Schema Changes

B

B B BB

Schema Changes are broadcast messages

Page 55: Fractal tree-technology-and-the-art-of-indexing

The Art of Indexing®

Fractal Tree Indexes: Schema Changes

B

B B BB

Schema Changes are broadcast messages

Insertion into root is fast, changes are immediate

Page 56: Fractal tree-technology-and-the-art-of-indexing

The Art of Indexing®

Fractal Tree Indexes: Schema Changes

B

B B BB

Schema Changes are broadcast messages

Leaves get rewritten when broadcast message

makes it that far

Insertion into root is fast, changes are immediate

Schema change message still on root-

leaf path

Page 57: Fractal tree-technology-and-the-art-of-indexing

The Art of Indexing®

Analysis

Delivery system gives goodies:• Messages get moved, but each I/O pays for a lot of

movement

• You get very fast inserts

• You get Hot Schema Changes

Each flush carries lots of useful information• So it’s worth it to make nodes big

• No fragmentation, Better Compression

• Much better wear on SSDs