Home  >  Article  >  What does the arrangement of data stored on disk affect?

What does the arrangement of data stored on disk affect?

(*-*)浩
(*-*)浩Original
2019-10-26 09:15:073232browse

The way data is stored on disk affects the total time of I/O service.

What does the arrangement of data stored on disk affect?

Assume that each track is divided into 10 physical blocks, and each block stores 1 logical record. Logical records R1, R2,..., R10 are stored on the same track. The order of recording is as shown in the following table: (Recommended learning: web front-end video tutorial)

What does the arrangement of data stored on disk affect?

Assume that the rotation speed of the disk is 20ms/cycle, and the head is currently at the beginning of R1. If the system processes these records sequentially, using a single buffer, and the processing time of each record is 4ms, the maximum time to process these 10 records is 204ms; if the information storage is optimized and distributed, the minimum time to process 10 records is 60ms.

First of all, from the disk speed of 20ms/week, we can know that it takes 2ms to read a record.

One thing worth noting is:

The prerequisite for processing a record is to read it out. When processing the first record, it must be read first and then processed, so the time required to process R1 is 2ms 4ms. When R1 is processed, the head has been rotated to the position of R4. At this time, it must be adjusted to The position of R2 needs to go through R5, R6, R7, R8, R9, R10, R1, which takes 16ms. In addition, it takes 2ms to read R2 and 4ms to process the data. The total processing time of R2 should be 22ms.

By analogy, the time to process these 10 records is

2 4 (16 2 4) × 9 = 204ms

From the above analysis, we know that most Time is consumed in the process of moving the magnetic head back.

In order to reduce this time consumption, the arrangement order can be optimized. The optimized arrangement order should be: R1, R8, R5, R2, R9, R6, R3, R10, R7, R4. In this way, when R1 is processed, the head reaches the position of R2. Read R2 directly, process R2, and after processing R2, the head reaches the position of R3 again. By analogy, the reading and processing time of each record is: 2ms 4ms=6ms, so the total time is (2 4) × 10 = 60ms.

The above is the detailed content of What does the arrangement of data stored on disk affect?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn