Applications that are using a database are often running slower than one would expect by the power of the hard- and software. Both DB server and application server are running on powerful machines that are not even close to their limits.
The problem is the connection between the two servers. This connection is of course very fast, which can be quite impressive when huge amounts of data need to be transferred, all at once. Ideally think of the huge resultset of one query.
Typical database access operations need multiple accesses to the DB-server. Each one of these works according to a communication protocol. Usually this implies some round trips. So many small accesses to the database tend to slow the whole application, because it is mostly waiting for the connection.
What can be done about this?
First of all the real bottleneck should be identified before optimizing something that is not the problem.
It does make a lot of sense to optimize the application for larger and fewer queries, so more data is transferred at once. This may not be easy with frameworks, especially if eclipselink or hibernate is used. A typical anti pattern is to read a large number of records from the database and then fetch detail information for each record from another table, with one request for each record. This can usually be avoided by using complex SQL queries and it is sometimes worth the effort. As always optimizations should only be done where they are either not very intrusive or where the benefit is likely to justify them.
Another more general optimization is to put application and database on the same server. This is often not easy, because many system administrators do not like this too well. But if sufficient performance can only be achieved by putting all on one server, this is recommended. Maybe it is an advantage of NoSQL databases that system administrators do not know any best practices that suggest to install database and application on different servers, so they can be running on the same server, thus eliminating most (but not all) of the latency.