Creating a B+ Tree _________________________________

CNGAHEKQMFWLTZDPRXYS

A C G N

B+ Trees

1

CNGAHEKQMFWLTZDPRXYS

G

A C
B+ Trees

G H N
2

CNGAHEKQMFWLTZDPRXYS

G

A C E
B+ Trees

G H K N
3

CNGAHEKQMFWLTZDPRXYS

G K

A C E

G H

K N Q

B+ Trees

4

CNGAHEKQMFWLTZDPRXYS

G K

A C E F

G H

K M N Q

B+ Trees

5

CNGAHEKQMFWLTZDPRXYS

G K N

A C E F

G H

K M

N Q W

B+ Trees

6

CNGAHEKQMFWLTZDPRXYS

G K N

A C E F

G H

K L M

N Q T W

B+ Trees

7

CNGAHEKQMFWLTZDPRXYS

G K N T

A C E F

GH

K L M
B+ Trees

N Q

T W Z
8

CNGAHEKQMFWLTZDPRXYS

G K N T

A C E F
D (Split node)

GH

K L M

N Q

T W Z

B+ Trees

9

CNGAHEKQMFWLTZDPRXYS
(Split node)

D

G K N T

A C E F

GH

K L M

N Q

T W Z

B+ Trees

10

CNGAHEKQMFWLTZDPRXYS

K D G A C D E F N T GH K L M N Q T W Z

B+ Trees

11

CNGAHEKQMFWLTZDPRXYS

K D G
A C DE F G H

N T
K L M N P QR T WX Z
B+ Trees 12

CNGAHEKQMFWLTZDPRXYS
Right Sub-Tree

N T X
K L M N P Q R T W X Y Z

B+ Trees

13

CNGAHEKQMFWLTZDPRXYS
Right Sub-Tree

N Q T X
K L M N P Q R S T W X Y Z

B+ Trees

14

Speed in B+ Tree Index
• In processing a query, we traverse a path from the root to a leaf node. If there are K search key values in the file, this path is no longer than log(n/2) K , where n is number of links possible in any given node. • This means that the path is not long, even in large files. For a 4k byte disk block with a search-key size of 12 bytes and a disk pointer of 8 bytes, n is around 200. If n =100, a look-up of 1 million search-key values may take log50(1,000,000) = 4 nodes to be accessed. Since root is in usually in the buffer, so typically it takes only 3 or fewer disk reads.
B+ Trees 15