Tips: After reading the MySQL index behind the data structure and algorithm principles, inside there said:
"The designers of the database system have cleverly used the principle of disk pre-reading to set the size of a node equal to one page, so that each node needs only one I/O to be fully loaded." In order to achieve this, in the actual implementation of the B-tree also need to use the following techniques: each time a new node, directly request a page of space, so that a node can be physically stored in a page, in addition to the computer storage allocation is page-aligned, the implementation of a node only one time I/O. "
Then I do not understand what the page means, and read this super-detailed explanation of the hard disk: http://blog.csdn.net/hguisu/article/details/7408047
Below is some of my excerpts, want to look at the time to see this, want to see the detailed on the top of this.
For the page understanding:
Because say a sector 512byte, is 0.5k, a page is 4K, that is, a page is 8 sectors of the size, presumably so understand it.
We know that the information is stored on the hard drive, and it is not visible that there is anything in it, only some platters. assuming that you enlarge the disc with a microscope, you will see the uneven surface of the platter, the convex place is magnetized, the concave place is not magnetized, the raised place represents the number 1 (magnetization is 1), the concave place represents the number 0. Therefore, the hard disk can be binary to store representations of text, pictures and other information.
1, the composition of the hard disk
Hard disk We must not be unfamiliar, we can liken it to our computer storage data and information of the large warehouse. Generally speaking, no matter what kind of hard disk, it is composed of platters, head, disc spindle, control motor, head controller, data converter, interface, cache and so on.
Floor plan
Stereoscopic diagram
all platters are fixed on a rotating shaft, which is the disc spindle. All platters are absolutely parallel, with a head on each disc's storage surface, and the distance between the head and the platter is smaller than the diameter of the head hair . All heads are attached to a head controller, and the head controller is responsible for the motion of each head. The head can move along the radius of the disc, (actually oblique tangential motion), each head must also be coaxial at the same moment, that is, looking down from the top, all the heads are overlapping at any time (although there is already a multi-head independent technology, can not be limited by this). The disc rotates at a high speed at thousands of rpm, so that the head can read and write data to the specified position on the platter.
Since the hard drive is a high precision device, dust is the enemy, so it must be completely sealed.
2, the working principle of hard disk
The hard disk is logically divided into tracks, cylinders, and sectors.
The platters are divided into a series of concentric rings centered on the center of the disc, each concentric ring is called a track, and all tracks with the same radius form a cylindrical surface. Tracks are divided into small segments along the radius lines, each of which is called a sector, and each sector is the smallest storage unit of the disk. For the sake of simplicity, let's assume that the disk has only one platter and one head.
When data needs to be read from disk, the system will pass the logical address of the data to the disk, and the control circuit of the disk will translate the logical address into the physical address according to the addressing logic, that is, determine which track and which sector the data is to be read. In order to read the data in this sector, the head needs to be placed above this sector, in order to achieve this, the head needs to move to the corresponding track, this process is called seek, the time spent is called seek time, and then the disk rotation of the target sector is rotated to the head, the process of time is called rotation time.
That is, a request for a visit (read/write) The completion process consists of three actions:
1) Seek (time): Move the head to the specified track
2) rotation delay (time): Waits for the specified sector to be rotated from the head
3) data Transfer (time): The actual transmission between the disk and memory
Therefore, the time required to read the sector data (a piece of data) on disk:
ti/o=tseek +tla + n *tWM
which
Tseek for Seek time
TLA is rotation time
TWM for transfer time
3. Principle of locality and disk pre-reading
Due to the characteristics of the storage media, the disk itself is much slower than main memory, coupled with mechanical movement, disk access speed is often one of the hundreds of of main memory, so in order to improve efficiency, to minimize disk I/O. To do this, the disk is often not read strictly on-demand, but is read-ahead every time, even if only one byte is required, and the disk starts from this location, sequentially reading a certain length of data into memory. The rationale for this is the well-known local principle in computer science:
When a data is used, the data around it is usually used immediately.
The data that is required during the program run is usually relatively centralized.
Due to the high efficiency of disk sequential reads (no seek time required and minimal rotational time), pre-reading can improve I/O efficiency for programs with locality.
The length of the read-ahead is generally the integer multiple of the page. Page is the logical block of Computer Management memory, hardware and operating system tend to divide main memory and disk storage area into contiguous size equal blocks, each storage block is called a page (in many operating systems, the page size is usually 4k), main memory and disk in the page to exchange data. When the program to read the data is not in main memory, will trigger a page fault, the system will send a read signal to the disk, the disk will find the starting position of the data and sequentially read one or several pages back into memory, and then return unexpectedly, the program continues to run.
How the hard disk reads and writes