Monday, 4 January 2010

Tales from an Admin Perspective: Code Sleuth

We had a database that we kept getting complaints about, it kept getting slower and slower to do a specific task. I tracked it down to this code.

Can you spot this issue with this code?

Sub assignAclToSubRecord( viewName, docID )
    Dim counter As Integer
    Set vwSub = db.GetView( viewName )
    Set subDoc = vwSub.GetDocumentByKey( docID )
    Do While Not ( subDoc Is Nothing )
        subDoc.Authors_Variable_SpecificTI  = currentDoc.Authors_Variable_SpecificTI
        subDoc.AuthorsVariable = currentDoc.AuthorsVariable
        Call subDoc.Save(True,True)
        Set subDoc = vwSub.GetNextDocument( subDoc )
End Sub