This question keeps bugging me: Which type of access is the costliest (pl also mention the order, from inc to dec) - Network access, IO access or DB access?
How do we determine that?
Please respond to this...
It really depends on what your system is doing.
If you're application is making lots of round trips from the application to the db, and transferring a lot of data, then the network traffic could be the costliest, but I would say that this is rarely the bottleneck in a system.
If you are running very complex queries against the db, you have a large number of queries or your db just contains a shed-load of data, then the db might be the costliest. In my experience the db can cause the most problems.
Another thing to consider is the JVM of the application itself - if you have a high throughput of users, then garbage collection can become an issue as well.
As for IO, do you mean disk or another type of IO?
Thanks for the reply.
For the IO, I meant disk IO.
I want to discuss it a bit further. Consider the following scenario:
We have 2 computers across a network (intranet), say Computers A and B. Our program is running on A and tries to access a file. The file can be either on A or B. The system is set up in such a way that if the file is not found in A, it'll try to access it from B. Now consider these 2 cases:
Case-1: File is found in A (not in cache, but is there in the disk). So, the acess time is, lets say, D ms.
Case-2: File is not in A, but is in B's cache. So, the access time is N ms. (N for Network)
Now which one is greater, N or D?
We can apply the same scenario with DataBase as well. Database is on computer A. If the file is not in DB, we'll look for it in computer B.
Case-1: File found in DB, so access time is DB ms.
Case-2: File not in DB, but present in B's cache. So, the access time is N.
Which one is greater: N or DB?
Will the conclusion differ it is internet as opposed to intranet?
General speaking you can say the following about "ressource" access;
First is fastest;
Still general speaking a conclusion on you db/IO/Net question, would be that your database access is properly faster then then plain disk IO access, this is because the database will try to optimize IO (maybe caching in memory), and the network is a lot slower.
As I say this is general speaking because the behaviour of the actual running system is dependent on a lot of runtime factors, and of course on the hardware you are using. (network traffic can be very fast using optical fiber cabels)
Hope this answer helps.
The only way to know for sure for your specific situation is meassuring it.
Write proof of concepts, profile them, voila, instant answer.
Interesting question, so consider this:
DB is both Network and IO and usually is the costliest of the solutions. Network will follow and Local IO will be the least costly.
Artem D. Yegorovhttp://www.activexml.org
If you are accessing random data, each seek will cost a bit less than 10ms that'll limit you to 100 query per second per disk. You can use more disks and raid stripping... or more servers.