7

I want to know what exactly is sequential write and what is random write in definition. I will be even more helpful with example. I tried to google the result. But not much google explanation. Thanks

  • 1
    possible duplicate of [Difference between sequential write and random write](http://stackoverflow.com/questions/2100584/difference-between-sequential-write-and-random-write) – Raymond Chen Nov 28 '14 at 00:45
  • @RaymondChen they are just different question. I read that already. – f4fc2791e4473eb2ba41b5ddb445b2 Nov 28 '14 at 13:27
  • "When people talk about sequential vs random writes to a file, they're generally drawing a distinction between writing without intermediate seeks ("sequential"), vs. a pattern of seek-write-seek-write-seek-write, etc. ("random")." – Raymond Chen Nov 28 '14 at 17:07
  • Not sure how you missed it. It was the first sentence of the accepted answer. – Raymond Chen Nov 28 '14 at 21:10

1 Answers1

9

When you write two blocks that are next to each-other on disk, you have a sequential write.

When you write two blocks that are located far away from eachother on disk, you have random writes.

With a spinning hard disk, the second pattern is much slower (can be magnitudes), because the head has to be moved around to the new position.

Database technology is (or has been, maybe not that important with SSD anymore) to a large part about optimizing disk access patterns. So what you often see, for example, is trading direct updates of data in their on-disk location (random access) versus writing to a transaction log (sequential access). Makes it more complicated and time-consuming to reconstruct the actual value, but makes for much faster commits (and you have checkpoints to eventually consolidate the logs that build up).

Thilo
  • 257,207
  • 101
  • 511
  • 656