为用户和事件跟踪时间统计信息。
在下表中,[说明] 部分提供 SQL 数据类型。如果您使用 Java 或 .NET 编写脚本,则应该使用相应的数据类型。请参见 SQL-Java 数据类型和 SQL-.NET 数据类型。
只有当未指定任何后续参数时,事件参数才是可选的。例如,如果要使用参数 2,您必须使用参数 1。
| 项 | 参数 | 说明 |
|---|---|---|
| 1 | ml_username | VARCHAR(128) |
| 2 | event_name | VARCHAR(128) |
| 3 | num_calls | INTEGER |
| 4 | min_time | INTEGER。毫秒。 |
| 5 | max_time | INTEGER。毫秒。 |
| 6 | total_time | INTEGER。毫秒。 |
无。
time_statistics 事件可用于在同步过程中为任何用户收集时间统计信息。并且仅为有相应脚本的事件收集统计信息。该脚本在某一事件发生多次时收集汇总数据。它在进行用户、事件、表之间的时间比较时非常有用。
以下示例将统计信息插入到了 time_statistics 表中。
call ml_add_connection_script(
'ver1',
'time_statistics',
'INSERT INTO time_statistics (id, ml_user, table,
event_name, num_calls, min_time, max_time, total_time)
VALUES (ts_id.nextval,?,?,?,?,?,?)')下面的存储过程调用在同步脚本版本 ver1 时将名为 timeStatisticsConnection 的 Java 方法注册为 time_statistics 连接事件的脚本。
call ml_add_java_connection_script( 'ver1', 'time_statistics', 'ExamplePackage.ExampleClass.timeStatisticsConnection' )
下面是示例 Java 方法 timeStatisticsConnection。它输出 prepare_for_download 事件的统计信息。(这在开发时可能会有帮助,但会降低生产服务器的性能。)
public void timeStatisticsConnection(
String ml_username,
String table_name,
String event_name,
int num_calls, int min_time, int max_time,
int total_time )
{ if( event_name.equals( "prepare_for_download")
{ java.lang.System.out.println(
"prepare_for_download num_calls: " + num_calls +
"total_time: " + total_time ); } }下面的存储过程调用在同步脚本版本 ver1 时将名为 TimeStats 的 .NET 方法注册为 time_statistics 连接事件的脚本。
call ml_add_dnet_connection_script( 'ver1', 'time_statistics', 'TestScripts.Test.TimeStats' )
下面是示例 Java 方法 TimeStats。它输出 prepare_for_download 事件的统计信息。(这在开发时可能会有帮助,但会降低生产服务器的性能。)
public void TimeStats(
string user,
string eventName,
int numCalls,
int minTime,
int maxTime,
int totTime )
{ if( event_name=="prepare_for_download")
{ System.Console.WriteLine(
"prepare_for_download num_calls: " + num_calls +
"total_time: " + total_time ); } }SQL Anywhere Studio 9.0.2
版权所有 © 1989–2005 Sybase, Inc. 部分版权所有 © 2001–2005 iAnywhere Solutions, Inc. 保留所有权利。