Profile network java (jdbc)

Asked

Viewed 48 times

3

What tool can I use to evaluate the response time of a request (jdbc)

Ex:

query = "SELECT * FROM v$version WHERE banner LIKE '%Oracle%'";
ResultSet rs = stmt.executeQuery(query);
// linha de cima ⋀ 
// quanto tempo demorou nesse meio ?
// linha de baixo ⋁
rs.next();

In the log appears

15:58:35.175 INFO - 6. SELECT * FROM v$version WHERE banner LIKE '%Oracle%'; {executed in 1 ms}

In fact the query was executed with 1ms but there is a gap between running the query and loading this information.

What tool can I use to obtain such information?

1 answer

2

There are some commercial tools that can do this, but I’ve never used them.

Basically you must measure, somehow, the time elapsed in the call of the method executeQuery and related methods.

What is usually done in the companies where I worked is to instrumentalize the instances of Connection, Statement and correlates to measure times. Unfortunately each has a solution.

Here at Atlassian we have a plugin for Jira that, when loaded, is able to modify the classes at runtime and thus collect the information from Profiling.

This is done using a java agent, which makes it possible to add instrumentation to classes. View the Java documentation for more details.

There is a tutorial on how to make a mini profiler using instrumentation here.

The simplest alternative is to simply inject your summer Connection and correlated classes in the other classes of your system, as I mentioned above.

  • In my case the database is in the cloud and the application in another node, what I need and the time it takes application and database to communicate (request/response). With this information your answer changes or remains the same? Thank you for your attention.

  • @Brunorozendo If you want the total time, that is, including the time elapsed for Java to send the query to the database, the execution of the query and the time for the response from the database to Java, the solution is the same. On the other hand, if you want each individual value there the solution has to be at a lower level, for example, monitoring the network.

  • Thank you very much.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.