open recordset slow

  • If you can change the code that updates each record into an UPDATE statement that runs against the table, you will get a massive improvement in speed

    e.g. This loops through all records and multiplies a value by 10

    Set rs1 = New ADODB.Recordset

    With rs1

    .Open "LargeTable", CurrentProject.Connection, adOpenKeyset, adLockOptimistic

    Do While Not .EOF

    .Edit

    ![ValueField] = ![ValueField] * 10

    .Update

    .Movenext

    Loop

    .close

    End With

    Set rs1 = Nothing

    This can be accomplished with a single SQL statement

    Currentdb.Execute "UPDATE LargeTable SET ValueField = ValueField * 10", dbFailOnError

  • Thanks Chris. I'll review my recordset loops and detail and attempt to change them to UPDATE sql. In your experience, can most/all recordset looping operations be changed to a single UPDATE statement?

  • Many times you can, but sometimes you have to do it row by row

Viewing 3 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply