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.

asked Jun 14, 2016 at 6:57

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

answered Jun 14, 2016 at 14:12
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.

answered Jun 14, 2016 at 8:41

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.