473,606 Members | 3,100 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

The ISAMStats Method

ADezii
8,834 Recognized Expert Expert
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:
  1. Disk Reads - [0]
  2. Disk Writes - [1]
  3. Reads from Cache - [2]
  4. Reads from Read-Ahead Cache - [3]
  5. Locks placed - [4]
  6. Locks released - [5]
The basic syntax for the ISAMStats Method is as follows:
Expand|Select|Wrap|Line Numbers
  1. 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_ISAMStat s(), 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.
Expand|Select|Wrap|Line Numbers
  1. Public Sub GetDAO_ISAMStats(strQuery As String, Optional blnUseRecordset As Boolean)
  2. Const conDisk_Reads As Integer = 0
  3. Const conDisk_Writes As Integer = 1
  4. Const conReads_From_Cache As Integer = 2
  5. Const conReads_From_Read_Ahead_Cache As Integer = 3
  6. Const conLocks_Placed As Integer = 4
  7. Const conLocks_Released As Integer = 5
  8.  
  9. Dim dbISAM As DAO.Database, rstISAM As DAO.Recordset
  10.  
  11. Dim lngDiskReads As Long, lngDiskWrites As Long, lngReadsFromCache As Long
  12. Dim lngReadsFromReadAheadCache As Long, lngLocksPlaced As Long
  13. Dim lngLocksReleased As Long
  14.  
  15. DoCmd.Hourglass True
  16.  
  17. Set dbISAM = CurrentDb()
  18.  
  19. 'Reset all Meters
  20. Call DAO.DBEngine.ISAMStats(conDisk_Reads, True)
  21. Call DAO.DBEngine.ISAMStats(conDisk_Writes, True)
  22. Call DAO.DBEngine.ISAMStats(conReads_From_Cache, True)
  23. Call DAO.DBEngine.ISAMStats(conReads_From_Read_Ahead_Cache, True)
  24. Call DAO.DBEngine.ISAMStats(conLocks_Placed, True)
  25. Call DAO.DBEngine.ISAMStats(conLocks_Released, True)
  26.  
  27. If blnUseRecordset Then
  28.   Set rstISAM = dbISAM.OpenRecordset(strQuery, dbOpenSnapshot)
  29. Else
  30.   dbISAM.Execute strQuery
  31. End If
  32.  
  33. lngDiskReads = DAO.DBEngine.ISAMStats(conDisk_Reads)
  34. lngDiskWrites = DAO.DBEngine.ISAMStats(conDisk_Writes)
  35. lngReadsFromCache = DAO.DBEngine.ISAMStats(conReads_From_Cache)
  36. lngReadsFromReadAheadCache = DAO.DBEngine.ISAMStats(conReads_From_Read_Ahead_Cache)
  37. lngLocksPlaced = DAO.DBEngine.ISAMStats(conLocks_Placed)
  38. lngLocksReleased = DAO.DBEngine.ISAMStats(conLocks_Released)
  39.  
  40. Debug.Print "==========================================="
  41. Debug.Print "Statistics for (" & strQuery & ") - [" & IIf(blnUseRecordset, "Recordset", "Query") & "]"
  42. Debug.Print "Number of Records: " & Format$(DCount("*", "tblMain"), "#,#,#")
  43. Debug.Print "==========================================="
  44. Debug.Print "Disk Reads                     : " & Format$(lngDiskReads, "#,#,#")
  45. Debug.Print "Disk Writes                    : " & Format$(lngDiskWrites, "#,#,#")
  46. Debug.Print "Reads From Cache               : " & Format$(lngReadsFromCache, "#,#,#")
  47. Debug.Print "Reads From Read-Ahead Cache    : " & Format$(lngReadsFromReadAheadCache, "#,#,#")
  48. Debug.Print "Locks Placed                   : " & Format$(lngLocksPlaced, "#,#,#")
  49. Debug.Print "Locks Released                 : " & Format$(lngLocksReleased, "#,#,#")
  50. Debug.Print "==========================================="
  51.  
  52. If blnUseRecordset Then
  53.   rstISAM.Close
  54.   Set rstISAM = Nothing
  55. End If
  56.  
  57. DoCmd.Hourglass False
  58.  
  59. End Sub
Sub-Routine Call:
Expand|Select|Wrap|Line Numbers
  1. 'Code will Execute the Query - (blnUseRecordset = False)
  2. Call GetDAO_ISAMStats("qryISAMTest", False)
Generated Statistics:
Expand|Select|Wrap|Line Numbers
  1. ===========================================
  2. Statistics for (qryISAMTest) - [Query]
  3. Number of Records: 520,000
  4. ===========================================
  5. Disk Reads                     :    21,499
  6. Disk Writes                    :    17,862
  7. Reads From Cache               : 2,046,721
  8. Reads From Read-Ahead Cache    :    32,873
  9. Locks Placed                   :    16,514
  10. Locks Released                 :    16,256
  11. ===========================================
Dec 10 '07 #1
2 6104
dima69
181 Recognized Expert New Member
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 ?
Dec 10 '07 #2
ADezii
8,834 Recognized Expert Expert
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.
Dec 10 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

11
3611
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: virtual void do_bar() {} };
5
15356
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 the same class/static method definition statictly linked to my EXE and when I call InvokeMember(...), even though I got the Type from the new AppDomain, it calls the static method that I am staticly linked to and not the static method in the dynamicly...
4
2896
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)> myFunctor = SampleFunction; string result = myFunctor(7, true); Works great thanks to the help from this group. Here's the guts so far for two-arity:
7
1740
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 which to do it. As you can see from the object definition that it corresponds to a function that takes two inputs. When I try to run the script it does nothing. So what is wrong and how do I fix it? Here is the script. function...
5
3412
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 5), but fails on IIS 6 running on a Win2003 server. The web uses Pages derived from a custom class I wrote (which itself derives from Page) to provide some common functionality. The Page_Load handler the failing webpage starts out like this: ...
18
4725
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 class where only the "searched" property has a value. I expected to get the index into the arraylist where I could then get the entire class instance. However, the 'indexof' is never calling my overloaded, overrides Equals method. Here is the...
10
3362
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. Compiler: gcc 4.1, Linux Thanks,
9
5837
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 the static Parse method of the conversion class. if (InValue is string) return T.Parse((string)InValue); else return base.ConvertFrom(context, culture, InValue);
3
1346
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 looks like maybe not. Here is the test case I tried: class A(object):
0
8448
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
6796
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5987
isladogs
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5470
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3948
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4010
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2454
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1572
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1313
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.