Request logging logs individual requests received from, and responses sent to, an application. It is most useful for determining what the database server is being asked to do by the application.
Request logging is also a good starting point for performance analysis of a specific application when it is not obvious whether the database server or the client is at fault. You can use request logging to determine the specific request to the database server that might be responsible for problems.
Logged information includes such things as timestamps, connection IDs, and request type. For queries, it also includes the isolation level, number of rows fetched, and cursor type. For INSERT, UPDATE, and DELETE statements, it also includes the number of rows affected and number of triggers fired.
You can use the -zr server option to turn on request logging when you start the database server. You can redirect the output to a request log file for further analysis using the -zo server option. The -zn and -zs option let you specify the number of request log files that are saved and the maximum size of request log files.
The sa_get_request_times system procedure reads a request log and populates a global temporary table (satmp_request_time) with statements from the log and their execution times. For INSERT/UPDATE/DELETE statements, the time recorded is the time when the statements were executed. For queries, the time recorded is the total elapsed time from PREPARE to DROP (describe/open/fetch/close). That means you need to be aware of any open cursors.
Analyze satmp_request_time for statements that could be candidates for improvements. Statements that are inexpensive, but frequently executed, may represent performance problems.
You can use sa_get_request_profile to call sa_get_request_times and summarize satmp_request_time into another global temporary table called satmp_request_profile. This procedure also groups statements together and provides the number of calls, execution times, and so on.
Output to the request log can be filtered to include only requests from a specific connection or from a specific database, using the sa_server_option system procedure. This can help reduce the size of the log when monitoring a database server with many active connections or multiple databases.
CALL sa_server_option( 'RequestFilterConn' , connection-id );
You can obtain connection-id by executing CALL sa_conn_info( ).
CALL sa_server_option( 'RequestFilterDB' , database-id );
The database-id can be obtained by executing SELECT CONNECTION_PROPERTY( 'DBNumber' ) when connected to that database. Filtering remains in effect until explicitly reset, or until the database server is shut down.
CALL sa_server_option( 'RequestFilterConn' , -1 );
CALL sa_server_option( 'RequestFilterDB' , -1 );
use the -zr server option with a value of hostvars
execute the following:
CALL sa_server_option( 'RequestLogging' , 'hostvars' );
The request log analysis procedure, sa_get_request_times, recognizes host variables in the log and adds them to the global temporary table satmp_request_hostvar.