Logging Performance Data

In SQL Server 6.5, the ODBC SQL Server driver supports logging performance data.

    To log ODBC performance data
  1. Optionally, call SQLSetConnectOption with fOption set to SQL_COPT_SS_PERF_DATA_LOG and vParam set to the full path and filename of the performance data log file. For example:
    C:\\ODBCPERF.LOG
    
  2. Call SQLSetConnectOption with fOption set to SQL_COPT_SS_PERF_DATA and vParam set to SQL_PERF_START to start logging performance data.
  3. Call SQLGetConnectOption with fOption set to SQL_COPT_SS_PERF_DATA and pvParam set to the address of a pointer to a SQLPERF structure. This will set the pointer to point to a valid SQLPERF structure that contains current performance data.
  4. Optionally, call SQLSetConnectOption with fOption set to SQL_COPT_SS_LOG_NOW and vParam set to NULL to write a tab-delimited record of performance data to the performance data log file.
  5. Call SQLSetConnectOption with fOption set to SQL_COPT_SS_PERF_DATA and vParam set to SQL_PERF_STOP to stop logging performance data.

The SQLPERF structure is defined as follows:

typedef struct sqlperf
{
    // Application Profile Statistics
    DWORD TimerResolution;
    DWORD SQLidu;
    DWORD SQLiduRows;
    DWORD SQLSelects;
    DWORD SQLSelectRows;
    DWORD Transactions;
    DWORD SQLPrepares;
    DWORD ExecDirects;
    DWORD SQLExecutes;
    DWORD CursorOpens;
    DWORD CursorSize;
    DWORD CursorUsed;
    LDOUBLE PercentCursorUsed;
    LDOUBLE AvgFetchTime;
    LDOUBLE AvgCursorSize; 
    LDOUBLE AvgCursorUsed;
    DWORD SQLFetchTime;
    DWORD SQLFetchCount;
    DWORD CurrentStmtCount;
    DWORD MaxOpenStmt;
    DWORD SumOpenStmt;
    
    // Connection Statistics
    DWORD CurrentConnectionCount;
    DWORD MaxConnectionsOpened;
    DWORD SumConnectionsOpened;
    DWORD SumConnectionTime;
    LDOUBLE AvgTimeOpened;

    // Network Statistics
    DWORD ServerRndTrips;
    DWORD BuffersSent;
    DWORD BuffersRec;
    DWORD BytesSent;
    DWORD BytesRec;

    // Time Statistics;
    DWORD msExecutionTime;
    DWORD msNetworkServerTime;

}     SQLPERF;