QueryStats 2.0 for Access 95
(c) 1995 Trigeminal Software, Inc.

****Turn on WordWrap if using Notepad****

*************
To install QueryStats:
1) Copy QryStats.mda to your Access directory.
2) Load any database.
3) Choose Tools|Add-ins|Add-in Manager from the menu.
4) Choose QueryStats from the options listed and click on the "Install" button.

QueryStats 2.0 will be available from then on at any time from the Tools|Add-ins menu.
*************

STATEMENT OF PURPOSE

One of the biggest problems that comes with all of the new features and additions to Jet 3.0 and Access 95 is that there is often no clearcut way to decide "which way is faster" when given two or more choices.  Due to problems with the way that Windows 95, Access 95, and Jet 3.0 cache data, the only way to reliably benchmark many of these things has been to literally reboot after each test is run, and sometimes to run tests over and over again.  All of which wastes valuable development time.

This add-in is a utility that can help you to benchmark different optimizations of your applications.  Through use of the new (but unsupported/undocumented) ISAMStats method of the DBEngine object, you can take some of the mystery out of the optimization process.  The add-in will tell you all of the following things (and store them in a table in your database so you can keep track of all the benchmarks you run):

-- number of disk reads
-- number of disk writes
-- number of cache reads (refers to records already accessed)
-- number of read ahead cache (refers to records that Jet has in cache that it anticipates you needing)
-- number of locks placed
-- number of locks released (can release many locks at once so it may not always balance with number of locks placed)
-- how long the function/query took to run
-- the name of the function/query and the parameters used to run it
-- the return value of the function (when applicable)
-- the date/time that the function/query was tested

NOTE: The ISAMStats method only keeps track of the statistics that Jet uses on native (MDB) files.  The stats WILL include anything also done in background threads by Jet at the same time, so it is important to make sure that you are keeping track of what else Jet might be doing in addition to running your function. You may want to run benchmarks a few times to make sure you are getting consistent results.

QueryStats 2.0 can be used on:
-Select Queries
-Make Table Queries
-Append Queries
-Delete Queries
-Update Queries
-Append Queries
-Crosstab Queries
-Union Queries
-DDL (data definition language) Queries
-Domain functions (such as DCount and DSum)
-Other native and User-defined VBA functions

Although you can use QueryStats to benchmark native and user-defined functions that don't use Jet 3.0 at all, any function that does not use Jet will only be useful insofar as the "elapsed time to run the function" statistic is concerned.

***********

To use:
You can use it from any database at all.  Simply choose it from the Tools|Add-Ins menu.  In a moment the QueryStats form will come up (first you will be prompted to load up your old stats if it detects that you have run it before). Simply enter the name of a saved query (or choose "function" from the option group and then type in the name of any VBA function) and then hit the execute button.  

If the function has parameters, then type them in separately in the parameters box, delimited by commas.  For example, to use the DCount() function on the "Invoices" query in Northwind.MDB, you would use:

Function:   DCount
Parameters: "*","Invoices"

For Select, crosstab, and union queries, a recordset is open (with whichever constant you choose, dynaset or snapshot... although Access ignores an attempt to open a dynaset on read-only recordsets).  For other saved queries the Execute method is used (so make sure not to run action or DDL queries that you don't want to actually run as there is no turning back).

In order to test any other type of Jet operation, simply create a function (or functions) to perform the task.  For example, you can compare using explicit transactions to relying on implicit ones.  Or you can create a function that will test the effect of various DAO recorset or querydef options.  

Note that this function has no way to stop your own error trapping from working; if your function has an error in it then your function's error trapping will handle the message and QueryStats will assume that all is well until the function is done.  If your function has no error trapping, then the error-trapping in QueryStats will pick it up and give you the error code and message.  

***********

QueryStats 2.0 is provided free of charge.  It may be freely redistributed at any time PROVIDED no change is made to the form designs or VBA procedures.  Such modifications can be made on individual copies but this add-in is not licensed for release of such "altered" versions without the express written consent of Trigeminal Software, Inc.

Unfortunately, it is an unsupported tool (it has to be, since I am using an unsupported method to run it!), but please feel free to send me word of any problems or suggestions, so that they can be included in future versions.

**********
Special thanks to the lovely and wonderful Sue Hoegemeier. This add-in would not have been even half as cool without her inspiration (and incessant nagging).
Also special thanks to Ken Getz, from whom all good things in Access seem to come.
**********

December 11, 1995
Michael S. Kaplan
MSN/CIS Access MVP
Trigeminal Software, Inc.
CIS 102363,1726
MSN MichaelK_TSI
Internet 102363.1726@compuserve.com, MichaelK_TSI@msn.com






