home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / access / update11 / englisch / cdinst / perform.tx$ / perform.bin
Text File  |  1993-05-20  |  12KB  |  313 lines

  1.   --------------------------------------------------------
  2.   Performance Tuning Tips for Microsoft Access Version 1.1
  3.                        May 1993                        
  4.   --------------------------------------------------------
  5.  
  6.           (C) Copyright Microsoft Corporation, 1993
  7.  
  8. This document provides tips on tuning the performance 
  9. of Microsoft Access by adding or changing entries in 
  10. the MSACCESS.INI initialization file and by using 
  11. transactions.
  12.  
  13.  
  14. ------------------------
  15. How To Use This Document
  16. ------------------------
  17.  
  18. To view this document on screen using Microsoft Windows 
  19. Notepad, maximize the Notepad window.
  20.  
  21. To print this document, open it using Windows Write, 
  22. Microsoft Word, or another word processor. Then select the 
  23. entire document and format the text in 10-point Courier 
  24. font before printing.
  25.  
  26.  
  27. --------
  28. Contents
  29. --------
  30.  
  31. Tuning [ISAM] Entries in MSACCESS.INI
  32. Using Transactions To Maximize Data Throughput
  33.  
  34. -------------------------------------
  35. Tuning [ISAM] Entries in MSACCESS.INI
  36. -------------------------------------
  37.  
  38. Microsoft Access automatically provides default internal 
  39. settings that usually provide the best performance for 
  40. most common database operations. However, advanced users
  41. may want to tune these settings to provide maximum 
  42. performance for a particular system configuration or 
  43. application.
  44.  
  45. You can tune your Microsoft Access performance by adding 
  46. or changing entries in the [ISAM] section of the 
  47. MSACCESS.INI initialization file. (Setup installs this 
  48. file automatically in your Windows directory.) These 
  49. entries determine the sizes of data page and read-ahead 
  50. caches in memory, the amount of time data is held in a 
  51. page cache, and the number of times Microsoft Access will 
  52. retry a lock operation.
  53.  
  54. WARNING:  Determining the best settings for your system 
  55. configuration or application can be a time-consuming and
  56. difficult process, usually involving much trial and error.
  57. Casual users shouldn't try to add or change these entries.
  58.  
  59. Microsoft Access automatically includes a PageTimeout 
  60. entry in the [ISAM] section of the MSACCESS.INI file. 
  61. This entry sets the amount of time Microsoft Access holds 
  62. a data page in memory. For additional performance tuning, 
  63. you can add MaxBufferSize, ReadAheadPages, LockRetry, and 
  64. CommitLockRetry entries to this section. All of these 
  65. entries are described in this document.
  66.  
  67. Microsoft Access reads these settings at startup time. 
  68. You can change them while Microsoft Access is running, but 
  69. the changes won't take effect until you restart Microsoft 
  70. Access.
  71.  
  72.  
  73. PageTimeout (shared data only)
  74. ------------------------------
  75. The PageTimeout entry sets the amount of time, in tenths
  76. of a second, that Microsoft Access holds a data page in a 
  77. memory "page cache" if the database has been opened for 
  78. shared access. Microsoft Access reads data in 2-kilobyte 
  79. blocks of records, or "pages."
  80.  
  81. For example, when Microsoft Access reads a data page, it 
  82. places the data in the page cache. If Microsoft Access 
  83. receives another read request for the same data page 
  84. during the timeout period, it reads the data directly 
  85. from the page cache rather than from disk.
  86.  
  87. NOTE:  Access Basic ignores the PageTimeout setting unless 
  88. your code allows background processing by periodically 
  89. calling the DoEvents statement or function.
  90.  
  91. Maximum setting: 2147483647 (maximum long integer)
  92. Minimum setting: 0        
  93. Default setting: Setup automatically sets the PageTimeout 
  94.                  entry in MSACCESS.INI to 300. If you 
  95.                  remove the PageTimeout entry, Microsoft 
  96.                  Access uses a default PageTimeout 
  97.                  setting of 5.
  98.  
  99. EXAMPLE:  This example sets PageTimeout to 2 seconds.
  100.  
  101. PageTimeout=20
  102.  
  103.  
  104. MaxBufferSize
  105. -------------
  106. The MaxBufferSize entry sets the amount of memory, in 
  107. kilobytes, reserved for use as a page cache. Microsoft 
  108. Access reads data in 2K pages, placing the data in the 
  109. page cache. Once the data is placed in the cache, 
  110. Microsoft Access can use it wherever it is needed -- in 
  111. tables, queries, forms, or reports. 
  112.  
  113. When Microsoft Access receives a read request, it first 
  114. checks the data pages in the page cache. If the page 
  115. isn't in the cache, Microsoft Access reads the data page 
  116. from disk and then places it in the page cache. Microsoft 
  117. Access uses physical memory and if necessary virtual 
  118. memory to create the cache. All pages stay in the cache 
  119. until it is full and pages need to be flushed to make room 
  120. for new reads.
  121.  
  122. Maximum setting: 4096
  123. Minimum setting: 18
  124. Default setting: If there is no MaxBufferSize entry in  
  125.                  your MSACCESS.INI file, Microsoft Access  
  126.                  uses a default setting of 512.
  127.  
  128. NOTE:  Because Microsoft Access reads data in 2K pages, 
  129. it always uses an even MaxBufferSize setting. If you 
  130. type an odd number, Microsoft Access uses a 
  131. MaxBufferSize setting of 1 less than the number.
  132.  
  133. EXAMPLE:  This example sets MaxBufferSize to 4 megabytes.
  134.  
  135. MaxBufferSize=4096
  136.  
  137.  
  138. ReadAheadPages
  139. --------------
  140. The ReadAheadPages entry sets the size, in data pages, of 
  141. a "read-ahead" cache used by Microsoft Access for 
  142. sequential page reads. A sequential page read occurs when 
  143. Microsoft Access detects that data in a current read 
  144. request is on a data page adjacent on the physical disk 
  145. to the data page of the previous request. Microsoft Access 
  146. uses the read-ahead cache only when it detects that a 
  147. sequential read is taking place. 
  148.  
  149. If Microsoft Access detects a sequential page read, it
  150. reads the requested page plus the next N-1 pages in that 
  151. direction (where N is the ReadAheadPages setting), placing 
  152. the data pages in the read-ahead cache. If Microsoft Access 
  153. then detects a sequential read, it can make the next N 
  154. reads directly from the read-ahead cache.
  155.  
  156. The read-ahead cache increases the speed of sequential 
  157. reads, especially for reading data stored on a network. It 
  158. increases record updates per second (throughput) on a 
  159. network by sending a few large packets rather than many 
  160. small packets over the network.  
  161.  
  162. If possible, Microsoft Access places the read-ahead cache 
  163. in the first 640K of memory to take advantage of the 
  164. ability of Windows to read from and write to conventional 
  165. memory. 
  166.  
  167. If the read-ahead cache can't be placed in conventional 
  168. memory, Microsoft Access places it in high memory. Placing 
  169. the cache in high memory is less efficient than placing it 
  170. in conventional memory because Windows must copy all reads 
  171. and writes to its own buffer before completing the memory 
  172. operation.  
  173.  
  174. Maximum setting: 31
  175. Minimum setting: 0
  176. Default setting: If there is no ReadAheadPages entry in  
  177.                  your MSACCESS.INI file, Microsoft Access 
  178.                  uses a default setting of 8.
  179.  
  180. EXAMPLE:  ReadAheadPages=16
  181.  
  182. NOTE: Microsoft Access creates a separate read-ahead cache 
  183. for each database open on your computer. Each library 
  184. database has its own read-ahead cache.
  185.  
  186.  
  187. LockRetry
  188. ---------
  189. The LockRetry entry sets the number of times Microsoft 
  190. Access retries a page-locking operation before it reports 
  191. an error. For example, if a user tries to lock a data page 
  192. that is already locked by another user, the attempt will 
  193. fail. Microsoft Access will try to lock the page N more 
  194. times, where N is the LockRetry setting. 
  195.  
  196. If the attempt to lock the page still fails on the Nth 
  197. retry, Microsoft Access reports an error. 
  198.  
  199. Maximum setting: 2147483647 (maximum long integer)
  200. Minimum setting: 0
  201. Default setting: If there is no LockRetry entry in your 
  202.                  MSACCESS.INI file, Microsoft Access uses 
  203.                  a default setting of 20.
  204.  
  205. EXAMPLE:  LockRetry=6
  206.  
  207.  
  208. CommitLockRetry
  209. ---------------
  210. The CommitLockRetry entry is used in conjunction with the 
  211. LockRetry entry to set the number of retries that 
  212. Microsoft Access attempts when a user tries to lock a 
  213. record on a data page that is already locked by a 
  214. transaction. (For more information about transactions, see 
  215. "Using Transactions To Maximize Data Throughput" later in 
  216. this text file.)
  217.  
  218. If a user tries to lock a data page that is already locked 
  219. by a transaction, Microsoft Access will try to lock the 
  220. page N more times, where N is the product of the LockRetry 
  221. setting and the CommitLockRetry setting. For example, if 
  222. the LockRetry setting is 5 and the CommitLockRetry setting 
  223. is 6, Microsoft Access will try to lock the page 30 more 
  224. times.
  225.  
  226. Maximum setting: 2147483647 (maximum long integer)
  227. Minimum setting: 0
  228. Default setting: If there is no CommitLockRetry entry in 
  229.                  your MSACCESS.INI file, Microsoft Access 
  230.                  uses a default setting of 20.
  231.  
  232. EXAMPLE:  Assuming a LockRetry setting of 6, this example 
  233. causes Microsoft Access to retry locking a page locked by 
  234. a transaction 36 more times.
  235.  
  236. CommitLockRetry=6
  237.  
  238.  
  239. ----------------------------------------------
  240. Using Transactions To Maximize Data Throughput
  241. ----------------------------------------------
  242.  
  243. In a multiuser environment, you can further tune the 
  244. performance of Microsoft Access by using Access Basic 
  245. transactions for operations that update data. 
  246.  
  247. A transaction is a series of operations that must execute 
  248. as a whole or not at all. You mark the beginning of a 
  249. transaction with the BeginTrans statement. You use the 
  250. Rollback or CommitTrans statement to end a transaction. 
  251. (For more information about transactions, search Help for 
  252. "transactions" or see "Using Transactions" in Chapter 8, 
  253. "Manipulating Data," in Introduction to Programming.)
  254.  
  255. You can usually increase the record updates per second 
  256. (throughput) of an application by placing operations 
  257. that update data within an Access Basic transaction. The 
  258. following example from Chapter 8 in "Introduction to 
  259. Programming" (pages 118-119) illustrates how you can use 
  260. transactions in a function that transfers funds between 
  261. two bank accounts.
  262.  
  263. Function TransferFunds(FromAccount, ToAccount, CustomerID, Amount)
  264.     ' Transfers Amount from CustomerID's FromAccount to ToAccount.
  265.     ' Returns 0 if successful, nonzero error value if unsuccessful.
  266.   Dim db As Database, Source As Dynaset, Destination As Dynaset
  267.   On Error Resume Next
  268.   Set db = CurrentDB()
  269.   Set Source = db.CreateDynaset(FromAccount)
  270.   Set Destination = db.CreateDynaset(ToAccount)
  271.   If Err Then     ' Error with a field or table.
  272.     On Error GoTo 0
  273.     TransferFunds = Err
  274.     Exit Function  
  275.   End If
  276.   Source.FindFirst "[Cust ID] = " & CustomerID
  277.   Destination.FindFirst "[Cust ID] = " & CustomerID
  278.   If Not (Source.NoMatch Or Destination.NoMatch) Then
  279.     If Source!Balance >= Amount Then
  280.       BeginTrans
  281.       Source.Edit
  282.       Source![Balance] = Source![Balance] - Amount
  283.       Source.Update
  284.       Destination.Edit
  285.       Destination![Balance] = Destination![Balance] + Amount
  286.       Destination.Update
  287.       If Err Then
  288.         TransferFunds = -1  ' One or both updates didn't succeed.
  289.         Rollback            ' Roll back changes.
  290.       Else
  291.         TransferFunds = 0   ' No error.
  292.         CommitTrans         ' Commit changes.
  293.       End If
  294.     Else
  295.       TransferFunds = -2    ' Insufficient funds.
  296.     End If
  297.   Else
  298.     TransferFunds = -3      ' Account doesn't exist.
  299.   End If
  300.   Source.Close
  301.   Destination.Close
  302. End Function
  303.  
  304. TIP:  Because Microsoft Access locks data pages used in a 
  305. transaction until the transaction ends, using transactions
  306. will prevent access to those data pages while the transaction 
  307. is pending. If you use transactions, try to find a balance 
  308. between data throughput and data access.
  309.  
  310.  
  311.  
  312.  
  313.