Please have a look at this preformance extract on one of my JDBC transactions. The query was served by DB2 eventually. It took DB2 a couple of millis. Still, the query did not come back with results for 4.5 minutes !!!
Where am I spending my time?
Here is a summary of the TMON for DB2 collection analysis:
TOT CPU 0:00.02
I/O WT 0:00.02
The architecture layers include a web client creating requests to a Java servlet which dispatches the request to the appropriate delegates for processing. The DAO layer issues a JDBC connection request, then submits the call to DB2 via DB2 Connect.
The delays are clearly happening on the host before DB2 gets to process the request or sometime after. Not during, otherwise that would show up as DB2 time.
The best way to go forward is to extract time from log files (assuming you are printing the same) spent in each of these layers. By doing this, you can exactly know which component is causing the issue.
For eg: User Action <-> UI/Browser <-> App Server <-> Network <-> Database <-> O/s disk
Make sure you execute the query in db2 exclusively and check to see if all indexes etc are present & update statistics. We have come across similar issue earlier and we resolved it by identifying a component in which the max time was spent. Presumably, it was not in db...
In my experience, if there is a db issue then it will show up. Involve the right people and prepare a reproducable procedure to test this one out.