Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
chimp153
Starting Member
1 Post |
Posted - 2007-11-22 : 16:52:55
|
Hi all,I have a stored procedure that is called from a VB.NET application that takes an enormously long time to execute. In the QA it only takes 10sec but in the application it takes ages. The stored procedure is as follows:PROCEDURE NAME IS SPTOPTWENTYUSERSSELECT TOP 20 STRUSERNAME,SUM(INTBYTESRECVD) AS INTDOWNLOAD FROM TBLISAWEBLOGSWHERE DTELOGDATE BETWEEN @BEGINDATE AND @ENDDATEGROUP BY STRUSERNAMEORDER BY INTDOWNLOAD DESCThe code that runs it is as follows:sSQLString = SPTOPTWENTYUSERS Using cnn As New SqlConnection(GetPath) Try Dim cmd As New SqlCommand(sSQLString, cnn) Dim dr As SqlDataReader With cmd .CommandType = CommandType.StoredProcedure .CommandTimeout = 0 .Parameters.Add("@BEGINDATE", SqlDbType.DateTime) .Parameters.Add("@ENDDATE", SqlDbType.DateTime) .Parameters("@BEGINDATE").Value = dtpStartDate.Value .Parameters("@ENDDATE").Value = dtpEndDate.Value End With cnn.Open() dr = cmd.ExecuteReaderAny help on why this happens would be much appreciated.thanks |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2007-11-23 : 22:02:54
|
Open up SQL Profiler. Configure a trace to include the Performance\Showplan XML event. Start the trace. Run the application so that your code is executed. Run the query through Query Analyzer. Stop the trace. Compare the two execution plans.Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/ |
|
|
|
|
|