CodeSOD: Curious Queries about Performance

This post was originally published on this site

The Daily WTF

Andreas‘s employer recently upgraded their SQL Server databases to the latest version. During that upgrade, something went wrong, and performance dropped off a cliff. Applications which used to be merely slow to taking hours to query the data they required. Clearly, something was wrong in the upgrade process, but Andreas wasn’t a DBA, so that wasn’t specifically Andreas’s problem. Instead, there were plenty of badly performing blocks of code- maybe now was the time to try and optimize them.

That’s where this block of Visual Basic comes from.

Function Is_BookingCorr(CustomerID, Section, DocumentType, Spezification) Dim rst As ADODB.recordset rst.Open “Protocol”, CurrentProject.Connection, adOpenStatic, adLockOptimistic With rst .Filter = “[CustomerID]='” & CustomerID & “‘” .Filter = .Filter & ” and [Section]='” & Section & “‘” .Filter = .Filter & ” and [DocumentType]='” & DocumentType & “‘” .Filter = .Filter & ” and [Spezification]='” & Spezification & “‘” Is_BookingCorr = .RecordCount > 0 End

To read the full article click on the 'post' link at the top.