SEARCH THE LAB

What are you looking for?

ScienceReview information not provided

Why Random Reads and Sequential Reads Perform Differently

Review information not provided · 3 min

Start with the conclusion: the difference comes from how much fixed overhead each request has to pay. A sequential read spreads the cost of a single position…

Why Random Reads and Sequential Reads Perform Differently

Start with the conclusion: the difference comes from how much fixed overhead each request has to pay. A sequential read spreads the cost of a single positioning operation across a long stretch of data, while a random read pays that cost again for every request.

Mechanical hard drives make this easiest to see. Platter rotation and head seek are physical actions. For example, suppose a seek plus rotational latency totals about 8 ms and each request reads only 4KB; then at most about 125 requests complete per second, which works out to under 0.5 MB/s. On the same drive, a sequential read barely moves the head at all, and the bottleneck becomes the platter's linear velocity — a completely different order of magnitude. This is arithmetic derived from parameters, not a measured value, but it is enough to show where the gap comes from.

Solid-state drives have no heads, so the gap narrows, but it does not disappear. NAND flash reads in units of pages, commonly 4KB to 16KB, and writes in larger blocks; the controller also maintains a mapping table from logical addresses to physical pages. A 4KB random read request has to look up the table, locate a specific page on a specific die, and then transfer over a channel; a sequential read can hit the same batch of pages consecutively, letting the controller and channels pipeline the work. Random reads also lower the controller cache hit rate, and once the queue gets deep, scheduling overhead becomes visible.

The operating system amplifies this difference as well. When the file system detects an access pattern with consecutive offsets, it starts readahead, pulling later pages into the page cache in advance; random access does not fit that pattern, so readahead mostly does not trigger, and every request waits for real I/O. Databases are the same: a point lookup on a B-tree index is several random page accesses, while a full table scan or range scan is close to sequential; columnar storage keeps the same column contiguous precisely to turn analytical queries into sequential reads.

But "sequential is always faster" is an oversimplification. First, if the data is already in the page cache or the SSD's cache, the gap between random and sequential shrinks to almost nothing. Second, NVMe devices support very high queue depths, and multithreaded random reads can pull throughput up through parallelism; high IOPS does not mean low per-request latency. Third, in small-file scenarios metadata overhead dominates — reading 100 1KB files can be slower than reading one 100KB file, and the reason is not "randomness" itself. Fourth, sequential reads of large files can crowd out the cache, evicting hot data and actually slowing other workloads. Fifth, on mechanical drives the difference between sequential and random writes is even larger, because writes also involve block erase and garbage collection — but here we are only discussing reads.

A practical way to judge is to look first at request size and offset distribution. When offsets are highly scattered and requests are very small, the optimization direction is to reduce the number of requests or increase parallelism; when offsets are consecutive, the bottleneck is usually bandwidth and readahead policy. Running sequential and random modes separately with tools like fio, varying block size and queue depth, is how you map the real curve of this hardware and file system — but watch out for caching, file size, and warm-up, or the numbers are meaningless.

What engineering can do is turn random into sequential or reduce the number of random operations: batch and merge small requests, fetch data by primary-key ranges, add appropriate indexes to queries, use log-structured storage to organize writes into appends, and keep hot data resident in memory. The costs must be acknowledged too: indexes take up space, log-structured storage has read amplification, and readahead can waste bandwidth. Which approach to choose depends on whether the access pattern is mostly point lookups or mostly scans, and on whether latency or throughput is the hard requirement.