Search code examples
jdbcmariadbheidisql

How to get the network cost in one MariaDB query using JDBC?


When I query using HeidiSql, the console will give the info like this:

/* Affected rows: 0  Found rows: 2,632,206  Warnings: 0  Duration for 1 query: 0.008 sec. (+ 389.069 sec. network) */

I want to use JDBC to do the performance testing on our database.

So distinguish the network cost and the actual query cost is important in my case.

How to get the network cost in one MariaDB query using JDBC? Is it possible?


Solution

  • In HeidiSQL, I am defining the query duration as the time which mysql_real_query took to execute.

    That "network" duration is the time which mysql_store_result takes afterwards.

    See also:

    I guess JDBC has similar methods as the C API, so I guess the above mentioned logic from HeidiSQL should be easy to adapt.