The introduction

Before I read a lot of information, all said that the height of b+ tree is low, resulting in less disk I/O times, in fact, has not a good understanding of this point, these days to see some database knowledge, feel more in-depth understanding of this sentence, the following is my understanding.

Index access

How indexes are stored

Each time an index is inserted, bytes of data of a node are written into the file. The data of the node contains the address of the next node. The minimum storage unit in the database is one page. Then the address of the latter node can be represented by the page number and the in-page offset.

How is the index retrieved

Need to find, for example, the index for 3 nodes, to start from the root node, the index is not found, then get to the next node from the root node within the page number and page migration (not necessarily save the offset, can be through some algorithms calculate the page number and page migration), which once again to look for to the node in the document. Why read node by node, because the length of the data can be variable, and you don’t know how many bytes the next node will read before it is complete.

conclusion

Let’s look at the problem again, an operation that reads a file, we can think of it as an operation that deals with disk, and the goal is to keep the operation that reads a file as little as possible. So the more data you can read from a file at a time, the better the performance. Is it best if I read all the data in the file at once? Obviously not, although we say is the number of read a file to the less, the better, but the actual amount is mapped to a file system on disk, disk and the kernel for data exchange with ceiling, the operating system to help us do the processing, try to get the file system block for a file to a disk block, if we read too much, In fact, the number of disk I/OS does not actually decrease.