title: What is the Speed Difference Between Database and Web Service Calls?
body: <p>All things being equal, and in the most simple form, which is faster? <br />
  1.) A call to a web service method <br />
  2.) A call to a database</p>
  
  <p>For example, assume that you have a simple web service that just returns an integer that is calculated in X time. You also have a database that, when queried in th right way, also takes X time to calculate the answer. (So the <strong>compute time is the same in both cases</strong>) In both cases, assume the amount of data both directions is the same, say, a single 32-bit integer, for simplicity.</p>
  
  <p>Thus far, the calculation times of both the web service and the database are exactly the same.</p>
  
  <p>The environment is 1 application server, where the app resides, and 1 other server that is holding both the web service and the database. There is nothing else going on in the environment other than the application calling either the web service or database repeatedly. <strong>This all within one single LAN</strong>, so any network latency is equal.</p>
  
  <p>From an application, which will be faster, the call to the database, or the call to the web service?</p>
  
  <p>What I am trying to isolate, I guess, is which is more heavy-weight. Does the set up, open, close, tear down of a database connection end up slower than that for a web service,   or is it the same? Additionally, if there are other things, such as parsing the result from a web service, how do they affect the speed?</p>