Quantcast
Viewing all articles
Browse latest Browse all 35

MySQL overhead of calling a Stored Procedure

Within Java, we access MySQL (v5.5.40) via JDBC -- a prepare statement, setting parameters then calling the stored procedure. It appears that every execute() has the overhead of 4 meta-calls (per MySQL query log) preceding the actual SP call:

SELECT name, type, comment FROM mysql.proc WHERE name like...SHOW FUNCTION STATUS LIKE 'sp_one'SHOW PROCEDURE STATUS LIKE 'sp_one'SHOW CREATE PROCEDURE `db-name`.`sp_one`CALL sp_one()

Is this the expected behavior on the server side? It just doesn't seem very efficient.

Here is the example of how we use the API:

  conn = DriverManager.getConnection(..);  stmt = conn.prepareCall("{call sp_one(?,?)}");  stmt.setString(1, "a");  stmt.setString(2, "b");  stmt.execute();

Please note that the following is true:

  • CallableStatement.getMetadata() is not used
  • Parameters are accessed by index, not by name

Thanks!


Viewing all articles
Browse latest Browse all 35

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>