time_statistics table event

Tracks time statistics.

Parameters

In the following table, the description provides the SQL data type. If you are writing your script in Java or .NET, you should use the appropriate corresponding data type. See SQL-Java data types and SQL-.NET data types.

In SQL scripts, you can specify event parameters by name or with a question mark, but you cannot mix names and question marks within a script. If you use question marks, the parameters must be in the order shown below and are optional only if no subsequent parameters are specified (for example, you must use parameter 1 if you want to use parameter 2). If you use named parameters, you can specify any subset of the parameters in any order.

Parameter name for SQL scripts

Description

Order

s.remote_id VARCHAR(128). The MobiLink remote ID. You can only reference the remote ID if you are using named parameters. Not applicable

s.username

VARCHAR(128). The MobiLink user name.

1

s.table

VARCHAR(128). The table name.

2

s.event_name

VARCHAR(128)

3

s.number_of_calls

INTEGER. The number of times the script was called.

4

s.minimum_time

INTEGER. Milliseconds. The shortest time it took to execute a script during the synchronization of this table.

5

s.maximum_time

INTEGER. Milliseconds. The longest time it took to execute a script during the synchronization of this table.

6

s.total_time

INTEGER. Milliseconds. The total time it took to execute all scripts in the synchronization of the table. (This is not the same as the length of the synchronization.)

7

Default action

None.

Remarks

The time_statistics table event allows you to gather time statistics for any user and table during synchronization. The statistics are gathered only for those events for which there is a corresponding script. The script gathers aggregate data for occasions where a single event occurs multiple times. The script can be especially useful for time comparisons across users, events and tables.

See also
SQL example

The following example inserts statistical information into the time_statistics table.

CALL ml_add_table_script (
 'ver1',
 'table1',
 'time_statistics',
 'INSERT INTO time_statistics(
   ml_user, 
   table, 
   event_name, 
   number_of_calls,
   minimum_time, 
   maximum_time, 
   total_time)
  VALUES (
   {ml s.username}, 
   {ml s.table}, 
   {ml s.event_name}, 
   {ml s.number_of_calls}, 
   {ml s.minimum_time}, 
   {ml s.maximum_time}, 
   {ml s.total_time} )' );
Java example

The following call to a MobiLink system procedure registers a Java method called timeStatisticsTable as the script for the time_statistics table event when synchronizing the script version ver1.

CALL ml_add_java_table_script(
  'ver1',
  'table1',
  'time_statistics',
  'ExamplePackage.ExampleClass.timeStatisticsTable' )

The following is the sample Java method timeStatisticsTable. It prints statistics for the upload_old_row_insert event.

public String timeStatisticsTable(
  String username,
  String tableName,
  String eventName,
  int numberOfCalls, 
  int minimumTime, 
  int maximumTime,
  int totalTime ) {
  if( eventName.equals( "upload_old_row_insert") ) {
    java.lang.System.out.println(
     "upload_old_row_insert num_calls: " + numCalls +
     "total_time: " + totalTime ); 
  } 
  return ( null );
}
.NET example

The following call to a MobiLink system procedure registers a .NET method called TimeTableStats as the script for the time_statistics table event when synchronizing the script version ver1 and the table table1.

CALL ml_add_dnet_table_script(
  'ver1',
  'table1',
  'time_statistics',
  'TestScripts.Test.TimeTableStats'
)

The following is the sample .NET method TimeTableStats. It prints statistics for the upload_old_row_insert event.

public string TimeTableStats(
  string user,
  string table,
  string eventName,
  int numberOfCalls,
  int minimumTime,
  int maximumTime,
  int totTime ) {
  if( event_name == "upload_old_row_insert") {
    System.Console.WriteLine(
      "upload_old_row_insert num_calls: " + num_calls +
      "total_time: " + total_time ); 
  } 
  return ( null );
}