2

My question is simple, is there any way to calculate, number of times a stored procedure is called on applications or executed on MySQL server.

For example:

Procedure name: sptest

Executing procedure: call sptest(1);

Is there any way to identify number of time the statement CALL sptest(1) executed on server.

Thanks in advance.

2 Answers 2

0

Look I do it this way in an audit table, each time this function is executed I put it at the foot of the procedure and called each time the query is run.enter image description here

enter image description here

and consultation is : update audit set calls = calls + 1 where func = 'sptest' ;

In this way you can already know how many times was called and the date

1

You can create a mapping table with two columns, one key (a string containing the called procedure name plus arguments if you need that) and one value (an integer containing the number of times the corresponding procedure has been called).

The first thing you do in your procedure you want to monitor is to update the mapping table to record the procedure call (by incrementing the counter). This logic you can encapsulate in another stored procedure.

This approach will be inconvenient if you need to monitor a large number of stored procedures, but will work for a small number.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.