Thursday, December 3, 2009

Stored Proc vs Straight SQL

A quick one today.  Last night I was playing with some SQL I have been looking at, trying to finish it off so that I could wrap it into a stored proc for release.  It was taking about 15-25 seconds to complete, which given what I was doing was to be expected.  But after I put it into a stored proc that time dropped to 4-7 seconds.  Lesson of the day: when writing complex SQL, wrap it in a stored proc.