Performance

ODBC and SQL Server

ODBC and SQL Server

Performance

The MFCPerf sample illustrates two things: tuning the MFC ODBC database classes for performance, and capturing and interpreting Microsoft® SQL Server™ ODBC driver performance data.

The sample uses advanced features of the MFC ODBC database classes and must be built with MFC version 4.2 or later. Although MFC is ODBC 2.x compliant, the MFCPerf sample uses features of the SQL Server ODBC driver available only in SQL Server 2000. The application must be built with ODBC 3.x header files and libraries.

The sample is an MFC MDI application that uses the Northwind sample database.

The application includes three documents. Two of the documents share a single view that displays customer order history. These documents are selected using the File\New Fast or File\New Slow menu items. One of the documents is identified as "slow." It uses MFC filter strings to execute SELECT statements, retrieving data from the Northwind Orders and OrderDetails tables. The second document, identified as "fast," uses parameterized execution of a SQL Server stored procedure to accomplish the same task.

The PerfTest menu, available when no document windows are open, automates creation of one of each document and steps through 20 client records. The process captures the SQL Server performance statistics for each document and displays them. The "fast" document shows a dramatic decrease in server roundtrips and a corresponding drop in data moved across the network.

Functions Illustrated
SQLAllocHandle SQLSetConnectAttr CRecordSet::Requery
SQLDataSources CDatabase::Open CRecordSet::MoveNext
SQLGetConnectAttr CRecordSet::Open CRecordSet::IsEOF