This week's Tip is basically geared to Power Access Users and Gurus who demand the ultimate in efficiency within their Applications. It involves an undocumented feature of Jet 4, and is a technique you can use to return a variety of pieces of information relating to Disk Reads and Writes. It is a Method of the DBEngine Object, and as such is restricted to DAO. Next week, we will discuss comparable functionality in ADO.
The ISAMStats Method is useful when you use it to compare two possible ways of doing something. Using this Method, you can retrieve information on six important statistics: - Disk Reads - [0]
- Disk Writes - [1]
- Reads from Cache - [2]
- Reads from Read-Ahead Cache - [3]
- Locks placed - [4]
- Locks released - [5]
The basic syntax for the ISAMStats Method is as follows: - lngReturn = DBEngine.ISAMStats(option, [reset])
where option is a Long Integer representing one of the above listed values for each reported statistic, and reset is an optional Boolean value that, when set to True, tells Jet to reset the counter for this particular option.
I will not demonstrate this Method via a Sub-Routine Procedure, GetDAO_ISAMStats(), which accepts the name of a Query or SQL String to execute, and an Optional Argument indicating whether the code should attempt to open a Recordset or Open a Query.
For purposes of this demonstration, I've chosen to Execute a Stored Query (strQuery = qryISAMStats, blnUseRecordset = False). This Query is an Update Query, and is based on a Table consisting of 520,000 Records, 342,000 of which are updated in the process. I will also show you the Statistics generated from the Function, and hopefully, you will see how valuable this Method can be in analyzing various Query Execution Plans. - Public Sub GetDAO_ISAMStats(strQuery As String, Optional blnUseRecordset As Boolean)
-
Const conDisk_Reads As Integer = 0
-
Const conDisk_Writes As Integer = 1
-
Const conReads_From_Cache As Integer = 2
-
Const conReads_From_Read_Ahead_Cache As Integer = 3
-
Const conLocks_Placed As Integer = 4
-
Const conLocks_Released As Integer = 5
-
-
Dim dbISAM As DAO.Database, rstISAM As DAO.Recordset
-
-
Dim lngDiskReads As Long, lngDiskWrites As Long, lngReadsFromCache As Long
-
Dim lngReadsFromReadAheadCache As Long, lngLocksPlaced As Long
-
Dim lngLocksReleased As Long
-
-
DoCmd.Hourglass True
-
-
Set dbISAM = CurrentDb()
-
-
'Reset all Meters
-
Call DAO.DBEngine.ISAMStats(conDisk_Reads, True)
-
Call DAO.DBEngine.ISAMStats(conDisk_Writes, True)
-
Call DAO.DBEngine.ISAMStats(conReads_From_Cache, True)
-
Call DAO.DBEngine.ISAMStats(conReads_From_Read_Ahead_Cache, True)
-
Call DAO.DBEngine.ISAMStats(conLocks_Placed, True)
-
Call DAO.DBEngine.ISAMStats(conLocks_Released, True)
-
-
If blnUseRecordset Then
-
Set rstISAM = dbISAM.OpenRecordset(strQuery, dbOpenSnapshot)
-
Else
-
dbISAM.Execute strQuery
-
End If
-
-
lngDiskReads = DAO.DBEngine.ISAMStats(conDisk_Reads)
-
lngDiskWrites = DAO.DBEngine.ISAMStats(conDisk_Writes)
-
lngReadsFromCache = DAO.DBEngine.ISAMStats(conReads_From_Cache)
-
lngReadsFromReadAheadCache = DAO.DBEngine.ISAMStats(conReads_From_Read_Ahead_Cache)
-
lngLocksPlaced = DAO.DBEngine.ISAMStats(conLocks_Placed)
-
lngLocksReleased = DAO.DBEngine.ISAMStats(conLocks_Released)
-
-
Debug.Print "==========================================="
-
Debug.Print "Statistics for (" & strQuery & ") - [" & IIf(blnUseRecordset, "Recordset", "Query") & "]"
-
Debug.Print "Number of Records: " & Format$(DCount("*", "tblMain"), "#,#,#")
-
Debug.Print "==========================================="
-
Debug.Print "Disk Reads : " & Format$(lngDiskReads, "#,#,#")
-
Debug.Print "Disk Writes : " & Format$(lngDiskWrites, "#,#,#")
-
Debug.Print "Reads From Cache : " & Format$(lngReadsFromCache, "#,#,#")
-
Debug.Print "Reads From Read-Ahead Cache : " & Format$(lngReadsFromReadAheadCache, "#,#,#")
-
Debug.Print "Locks Placed : " & Format$(lngLocksPlaced, "#,#,#")
-
Debug.Print "Locks Released : " & Format$(lngLocksReleased, "#,#,#")
-
Debug.Print "==========================================="
-
-
If blnUseRecordset Then
-
rstISAM.Close
-
Set rstISAM = Nothing
-
End If
-
-
DoCmd.Hourglass False
-
-
End Sub
Sub-Routine Call: - 'Code will Execute the Query - (blnUseRecordset = False)
-
Call GetDAO_ISAMStats("qryISAMTest", False)
Generated Statistics: - ===========================================
-
Statistics for (qryISAMTest) - [Query]
-
Number of Records: 520,000
-
===========================================
-
Disk Reads : 21,499
-
Disk Writes : 17,862
-
Reads From Cache : 2,046,721
-
Reads From Read-Ahead Cache : 32,873
-
Locks Placed : 16,514
-
Locks Released : 16,256
-
===========================================
2 6091
Ok - so we can see the statistics on running that query.
So what is your conclusion ? Is running stored query more efficient than using DAO recordset ?
Ok - so we can see the statistics on running that query.
So what is your conclusion ? Is running stored query more efficient than using DAO recordset ?
A comparative analysis between the two methodologies yielded very similar results on certain Query types. There is no conclusion, I had to leave something up to you guys to figure out (LOL). The number of Variables involved would be quite large, and it would be up to you, as the Developer, to figure out the Optimal solution for your specific set of circumstances.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Dave Rahardja |
last post by:
OK, so I've gotten into a philosophical disagreement with my colleague at
work. He is a proponent of the Template Method pattern, i.e.:
class foo
{
public:
void bar() { do_bar(); }
protected:...
|
by: Chris |
last post by:
Hi
I have a scenario where I've created another AppDomain to dynamically load a DLL(s) into. In this newly loaded DLL I want to call a static method on a class. The problem arise is that I have...
|
by: daniel.w.gelder |
last post by:
I wrote a template class that takes a function prototype and lets you
store and call a C-level function, like this:
inline string SampleFunction(int, bool) {..}
functor<string (int, bool)>...
|
by: greenflame |
last post by:
I am trying to make a matrix object. I have given it some properites. I
am trying to add a method. When I call the method by Test.showDims(...)
I want to only enter one input, that is the method by...
|
by: Nick Flandry |
last post by:
I'm running into an Invalid Cast Exception on an ASP.NET application that runs fine in my
development environment (Win2K server running IIS 5) and a test environment (also Win2K server
running IIS...
|
by: JohnR |
last post by:
From reading the documentation, this should be a relatively easy thing. I
have an arraylist of custom class instances which I want to search with
an"indexof" where I'm passing an instance if the...
|
by: Mihai Osian |
last post by:
Hi everyone,
Given the code below, can anyone tell me:
a) Is this normal behaviour ?
b) If it is, what is the reason behind it ? I would expect the
A::method(int) to be inherited by B.
...
|
by: Steve Richter |
last post by:
in a generic class, can I code the class so that I can call a static
method of the generic class T?
In the ConvertFrom method of the generic TypeConvert class I want to
write, I have a call to...
|
by: allendowney |
last post by:
Hi All.
In a complex inheritance hierarchy, it is sometimes difficult to find
where a
method is defined. I thought it might be possible to get this info
from the
method object itself, but it...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |