Client side cursor improves performance? If so, what am I doing wrong? I tried to create a performance test, using a table of 200,000 records.
The code is very simple. It simply loops through the table once, numbering the rows. It numbers them according to lastname.
Smith......1
Smith......2
Johnson...1
Johnson...2
Johnson...3
I am using ADO. When I specified "client-side cursor" (highligted in red), it ran so slow that I gave up after 10 minutes (I am simply running a regular Windows form on my desktop computer). When I removed that line of code, it took 13 seconds. (By the way, in DAO it took 9 seconds).
DAO.DBEngine.SetOption dbMaxLocksPerFile, 50000
Dim rs As New ADODB.Recordset
rs.CursorLocation = adUseClient
rs.Open "SELECT LastName, Index FROM Customers ORDER BY LastName", CurrentProject.Connection, adOpenStatic, adLockOptimistic
Dim index As Long, previousName As String
index = 0
previousName = rs("LastName")
With rs
Do While Not .EOF
If rs("LastName") = previousName Then index = index + 1 Else index = 1
rs("Index") = index
previousName = rs("LastName")
.MoveNext
Loop
End With
rs.Close
Set rs = Nothing
The code is very simple. It simply loops through the table once, numbering the rows. It numbers them according to lastname.
Smith......1
Smith......2
Johnson...1
Johnson...2
Johnson...3
I am using ADO. When I specified "client-side cursor" (highligted in red), it ran so slow that I gave up after 10 minutes (I am simply running a regular Windows form on my desktop computer). When I removed that line of code, it took 13 seconds. (By the way, in DAO it took 9 seconds).
DAO.DBEngine.SetOption dbMaxLocksPerFile, 50000
Dim rs As New ADODB.Recordset
rs.CursorLocation = adUseClient
rs.Open "SELECT LastName, Index FROM Customers ORDER BY LastName", CurrentProject.Connection, adOpenStatic, adLockOptimistic
Dim index As Long, previousName As String
index = 0
previousName = rs("LastName")
With rs
Do While Not .EOF
If rs("LastName") = previousName Then index = index + 1 Else index = 1
rs("Index") = index
previousName = rs("LastName")
.MoveNext
Loop
End With
rs.Close
Set rs = Nothing