问题
I'm using Access to iterate through a table, finding relevant information and bringing it together in a master table.
It loads up both recordsets, starts iterating through rsImport (Local <1000 row table), for each rsImport row, it looks to see if is a row that matches the UniqueRef in rsRecords, which it will then eithe update or add if it doens't exist.
F8 stepping through the complete code it actually pauses when it des the rsRecords.findfirst. If I remove the DateofAction part, it speeds up, so it's something to do with dates.
Any ideas?
I use:
Dim rsImport As DAO.Recordset, rsRecords As DAO.Recordset
Set rsImport = CurrentDb().OpenRecordset("SELECT * from tblFeedbackImport", dbOpenDynaset)
rsImport.MoveLast
rsImport.MoveFirst
Set rsRecords = CurrentDb().OpenRecordset("SELECT * from dbo_tblFeedbackRecords", dbOpenDynaset, dbSeeChanges)
rsRecords.MoveLast
rsRecords.MoveFirst
Do While rsImport.EOF = False
rsRecords.FindFirst "UniqueRef='" & Trim(rsImport!UniqueRef) & "' AND DateofAction=#" & Format(rsImport!DateofAction, "m-d-yy") & "#"
rsImport.MoveNext
Loop
I've a PrimaryIndex (Clustered) based on the two columns (UNiqueRef and DateOfAction).
来源:https://stackoverflow.com/questions/11397943/should-access-recordset-findfirst-have-performance-issues-with-dates