Performance question: Stored Procedures vs. Recordsets
I don't know if this is an appropriate place to ask this, but here goes:
I read this whole book now, and I am very surprised there is no real mention of using Stored Procedures when using SQL.
The last time I built a web app was with classic ASP and SQL 7, and the slowest part of the app was the SQL stuff. And Classic ASP allowed you to bring a Recordset in and manipulate the data in VBScript, and output the Presentation Layer using that Recordset, etc -- all the while the connection to SQL remained opened. This killed performance!
So what I did was absolutely 100% of all calls to SQL were done to Stored Procedures, which then did return a Recordset object in VBScript, BUT... then what I did was called .GetRows() to copy the data into an Array, then immediately destroy the Recordset, closing the connection to SQL. Then I built the Presentation Layer by iterating through the array.
This massively improved the performance. AND I optimized the execution plans for most Stored Procedures. The final result was an extremely fast and high-performance commercial web application that can support thousands of simultaneous users, and is still running today.
So I am surprised to see what ASP.NET 3.5 seems to be doing -- the way you put it is that SQLDataSource and LINQDataSource send actual SQL statements to the SQL server, rather than calling Stored Procedures. And also it seems as if the data-bound controls are using the data that is returned from SQL (Recordsets??) and maybe even leaving the connection to the database open the whole time while building the presentation layer?? If so, then Ug!
I also looked through the Wrox Professional ASP.NET 3.5 book and there is a brief mention that you can call Stored Procedures, but no mention as to optimizing your web app's performance, especially as related to SQL.
All seems a bit strange to me, just wondering if you had any thoughts. Is there something going on in .NET 3.5 that massively improves performance even though SQL statements are being sent to the database? In your examples you seem to just toss new connections to the database onto pages willy nilly, with no consideration as to what that might do to performance. Would you do something different on a commercial web app? Is there Wrox book that goes over optimizing the performance of your ASP.NET 3.5 web app??
Thank you very much... oh and BTW... great book!!
|