Beginning SQL

Beginning SQL Beginning SQL

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

Chapter 13 Gigahertz Networks or Compartmentalized Networks Another area where you can sometimes get large speed increases is by analyzing how your network is holding up to the load. Companies tend to grow haphazardly, adding employees all over the building and plopping down new workstations with little thought to what is happening to network traffic. In the Internet age, employees may be logging in to their workstations or the server using remote access, which can cause significant network overhead. Internet music and video downloads also cause massive congestion. It is not uncommon to end up with overloaded networks that can no longer keep up with the traffic being encountered. Oftentimes, new workstations can be purchased with gigahertz network cards. If the network is approaching saturation, moving up to gigahertz networks can open up the bandwidth enough to allow the applications to breathe again. Another thing that you can do is to compartmentalize the network such that different sections of the company come in to the server on separate routers, switches, or network interface cards (NICs). This is another area where there are tools to allow you to accurately measure whether the network is a bottleneck. Networks require expert assistance if you need to modify them, but if they are a bottleneck, then making those modifications can pay huge dividends. Caches A cache is a place where data is stored for fast access after it is retrieved from a location that takes significantly longer to access. This definition is flexible enough to work for all the various caches that you find on your computer, and there are many of them. The reason that you need to have at least a basic understanding of caches is that your queries are filling the caches with data, and your queries are also flushing the data out of the caches and replacing the old data with newer data. You might optimize a query and discover that it becomes lightning fast. The reason it becomes fast, however, may have less to do with your prowess as a SQL optimizer than because what you did allowed the data being worked on to remain in one of the caches. If this is the case, then if the amount of data suddenly exceeds the size of the cache, your query slows right back down again as the data needed gets flushed from the cache and replaced with other necessary data. Processor Cache The processor has a cache for instructions and data. This is typically a small cache, often as little as 8K for instructions and 32K for data, but in modern processors that amount may be in the hundreds of kilobytes or even megabytes. The processor caches are the fastest caches in the system. Getting data from the processor cache into the processor happens typically in a matter of one to a few clock cycles. At current processor speeds of 3GHz, a clock cycle is 0.33 billionths of a second, or one-third of one-billionth of a second. If your data fits in the processor cache, you are golden, and you get your results in the smallest possible time. Hard Disk Cache 352 The physical disk storage medium tends to require milliseconds (thousandths of a second) to access. Thus, getting data off the physical disk and into the disk cache (or into the system) takes as much as 10 milliseconds, or one-hundredth of a second — and that assumes that the disk is just sitting idle waiting for you to ask for data, a very rare occurrence. Thus, accessing data on the physical disk is more than 10 million times slower than accessing data in the processor cache. Remember that this is the time it takes to even start seeing the data.

Chapter 13<br />

Gigahertz Networks or Compartmentalized Networks<br />

Another area where you can sometimes get large speed increases is by analyzing how your network is<br />

holding up to the load. Companies tend to grow haphazardly, adding employees all over the building<br />

and plopping down new workstations with little thought to what is happening to network traffic. In the<br />

Internet age, employees may be logging in to their workstations or the server using remote access, which<br />

can cause significant network overhead. Internet music and video downloads also cause massive congestion.<br />

It is not uncommon to end up with overloaded networks that can no longer keep up with the<br />

traffic being encountered.<br />

Oftentimes, new workstations can be purchased with gigahertz network cards. If the network is<br />

approaching saturation, moving up to gigahertz networks can open up the bandwidth enough to allow<br />

the applications to breathe again. Another thing that you can do is to compartmentalize the network<br />

such that different sections of the company come in to the server on separate routers, switches, or network<br />

interface cards (NICs). This is another area where there are tools to allow you to accurately measure<br />

whether the network is a bottleneck. Networks require expert assistance if you need to modify<br />

them, but if they are a bottleneck, then making those modifications can pay huge dividends.<br />

Caches<br />

A cache is a place where data is stored for fast access after it is retrieved from a location that takes significantly<br />

longer to access. This definition is flexible enough to work for all the various caches that you find<br />

on your computer, and there are many of them. The reason that you need to have at least a basic understanding<br />

of caches is that your queries are filling the caches with data, and your queries are also flushing<br />

the data out of the caches and replacing the old data with newer data. You might optimize a query and<br />

discover that it becomes lightning fast. The reason it becomes fast, however, may have less to do with<br />

your prowess as a <strong>SQL</strong> optimizer than because what you did allowed the data being worked on to<br />

remain in one of the caches. If this is the case, then if the amount of data suddenly exceeds the size of the<br />

cache, your query slows right back down again as the data needed gets flushed from the cache and<br />

replaced with other necessary data.<br />

Processor Cache<br />

The processor has a cache for instructions and data. This is typically a small cache, often as little as 8K<br />

for instructions and 32K for data, but in modern processors that amount may be in the hundreds of kilobytes<br />

or even megabytes. The processor caches are the fastest caches in the system. Getting data from the<br />

processor cache into the processor happens typically in a matter of one to a few clock cycles. At current<br />

processor speeds of 3GHz, a clock cycle is 0.33 billionths of a second, or one-third of one-billionth of a<br />

second. If your data fits in the processor cache, you are golden, and you get your results in the smallest<br />

possible time.<br />

Hard Disk Cache<br />

352<br />

The physical disk storage medium tends to require milliseconds (thousandths of a second) to access.<br />

Thus, getting data off the physical disk and into the disk cache (or into the system) takes as much as 10<br />

milliseconds, or one-hundredth of a second — and that assumes that the disk is just sitting idle waiting<br />

for you to ask for data, a very rare occurrence. Thus, accessing data on the physical disk is more than 10<br />

million times slower than accessing data in the processor cache. Remember that this is the time it takes<br />

to even start seeing the data.

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

Saved successfully!

Ooh no, something went wrong!