Beginning SQL

Beginning SQL Beginning SQL

marjan.fesb.hr
from marjan.fesb.hr More from this publisher
20.07.2013 Views

When an application asks for data from the disk subsystem, the disk often reads a much larger block of data than asked for on the theory that the data around the data that was asked for is eventually requested as well. The hard disk or disks used to store data have a small cache that holds large blocks of data read off of the disk. This cache is typically 2M or 8M and physically resides on the circuit board inside of the hard disk. While this doesn’t sound like a lot, remember that it is quite common for databases to be split up into files stored on different hard disks. Thus, if a database is physically split into four different files and each file is the only thing on its disk, the disk subsystem itself is caching anywhere from 8M to 32M of the database at any one time. Figure 13-1 illustrates the relationship between the cache and the hard disk. Physical Hard Disk Figure 13-1 Head End Tail End Blocks of Data Move to Front Data Sent To Processor Main Memory Database Tuning Back to Head of Cache Bit Bucket (trash) As data is read off the disk, it is placed into memory in blocks, typically of the sector size. If any block of memory is requested by the system, that block is logically moved to the head of the cache using pointers to indicate the location of the blocks in the cache. Thus, blocks of cache asked for frequently stay in the cache, whereas blocks asked for less frequently move toward the tail end of the cache. If any block gets to the tail end, it is dropped out of the cache. This happens when the latest data being read into the cache fills the data block and is placed at the front of the cache. Once the data is in the hard disk cache, getting at it is still a lot slower than accessing the processor cache, but it is definitely much faster than physical disk access. The amount of time required to move data from the disk cache to memory depends on a slew of things, such as how the disks physically interface to the machine, but assuming a transfer rate of 50M per second, a good ballpark today is that you can get the entire contents of an 8M hard disk cache moved to memory in about one-sixth of a second. That doesn’t tell the whole story, however, because you can start to access it instantly — instantly being defined as a few hundred millionths of a second. Thus, you can see that the hard disk cache plays a very important role in speeding up disk-intensive applications, and a database is about as disk-intensive as applications get. Even so, it takes thousands and perhaps tens of thousands of processor cycles to start getting data from the disk cache into the processor itself so that it can be used by your application. 353

When an application asks for data from the disk subsystem, the disk often reads a much larger block of<br />

data than asked for on the theory that the data around the data that was asked for is eventually<br />

requested as well. The hard disk or disks used to store data have a small cache that holds large blocks of<br />

data read off of the disk. This cache is typically 2M or 8M and physically resides on the circuit board<br />

inside of the hard disk. While this doesn’t sound like a lot, remember that it is quite common for<br />

databases to be split up into files stored on different hard disks. Thus, if a database is physically split<br />

into four different files and each file is the only thing on its disk, the disk subsystem itself is caching anywhere<br />

from 8M to 32M of the database at any one time. Figure 13-1 illustrates the relationship between<br />

the cache and the hard disk.<br />

Physical<br />

Hard Disk<br />

Figure 13-1<br />

Head End Tail End<br />

Blocks of Data<br />

Move to Front<br />

Data Sent To<br />

Processor<br />

Main Memory<br />

Database Tuning<br />

Back to Head<br />

of Cache<br />

Bit<br />

Bucket<br />

(trash)<br />

As data is read off the disk, it is placed into memory in blocks, typically of the sector size. If any block of<br />

memory is requested by the system, that block is logically moved to the head of the cache using pointers<br />

to indicate the location of the blocks in the cache. Thus, blocks of cache asked for frequently stay in the<br />

cache, whereas blocks asked for less frequently move toward the tail end of the cache. If any block gets<br />

to the tail end, it is dropped out of the cache. This happens when the latest data being read into the cache<br />

fills the data block and is placed at the front of the cache.<br />

Once the data is in the hard disk cache, getting at it is still a lot slower than accessing the processor<br />

cache, but it is definitely much faster than physical disk access. The amount of time required to move<br />

data from the disk cache to memory depends on a slew of things, such as how the disks physically interface<br />

to the machine, but assuming a transfer rate of 50M per second, a good ballpark today is that you<br />

can get the entire contents of an 8M hard disk cache moved to memory in about one-sixth of a second.<br />

That doesn’t tell the whole story, however, because you can start to access it instantly — instantly being<br />

defined as a few hundred millionths of a second. Thus, you can see that the hard disk cache plays a very<br />

important role in speeding up disk-intensive applications, and a database is about as disk-intensive as<br />

applications get. Even so, it takes thousands and perhaps tens of thousands of processor cycles to start<br />

getting data from the disk cache into the processor itself so that it can be used by your application.<br />

353

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!