views:

65

answers:

2

I have a trigger on INSERT in MySQL 5.1. I want to know, how many times per second is it called. How can I do this?

A: 

Your best bet is to keep inserting into a table.

INSERT INTO trigger_log(query) VALUES(?)

This table has a datetime column that will automatically be updated, then you can do various queries to determine how many times/minute or hour, what period had the highest number of calls, etc.

Otherwise just update a table that has a column for day, hour, min, counter and just increment the counter for the current day/hour/min.

I don't like the second one as much as there is so much potential information being lost, but it would do what you want also.

James Black
A: 

There is no way to directly cound the number of triggers on the inserts. You could analyse the logfiles or you could alter your trigger (as the trigger acts on insert) to write an entry in a log table with auto_increment id and datetime. You can then analyze this table for any statistics.

Residuum