Reports information about the execution time for each line within procedures, functions, events, or triggers that have been executed in a database.
sa_procedure_profile(
[ filename
[, save_to_file ] ] )
Column Name | Data Type | Description |
---|---|---|
object_type | CHAR(1) | The type of object. See the Remarks section below for a list of possible object types. |
object_name | CHAR(128) | The name of the stored procedure, function, event, or trigger. If the object_type is C or D, then this is the name of the foreign key for which the system trigger was defined. |
owner_name | CHAR(128) | The object's owner. |
table_name | CHAR(128) | The table associated with a trigger (the value is NULL for other object types). |
line_num | UNSIGNED INTEGER | The line number within the procedure. |
executions | UNSIGNED INTEGER | The number of times the line has been executed. |
millisecs | UNSIGNED INTEGER | The time to execute the line, in milliseconds. |
percentage | DOUBLE | The percentage of the total execution time required for the specific line. |
foreign_owner | CHAR(128) | The database user who owns the foreign table for a system trigger. |
foreign_table | CHAR(128) | The name of the foreign table for a system trigger. |
Since the result set includes information about the execution times for individual lines within procedures, triggers, functions, and events, and what percentage of the total procedure execution time those lines use, you can use this profiling information to fine-tune slower procedures that may decrease performance.
Before you can profile your database, you must enable profiling.
If you want summary information instead of line by line details for each execution, use the sa_procedure_profile_summary procedure instead.
You must have EXECUTE privilege on the system procedure, as well as the the MONITOR or MANAGE PROFILING system privilege.
The following statement returns the execution time for each line of every procedure, function, event, or trigger that has been executed in the database:
CALL sa_procedure_profile( );
The following statement returns the same detailed procedure profiling information as the example above, and saves it to a file called detailedinfo.txt:
CALL sa_procedure_profile( 'detailedinfo.txt', 1 );
Either of the following statements can be used to load detailed procedure profiling information from a file called detailedinfo.txt:
CALL sa_procedure_profile( 'detailedinfo.txt', 0 ); CALL sa_procedure_profile( 'detailedinfo.txt' );