I have a query that is time to run from my windows application even though it runs fine within 2 seconds I run it directly in SSMS. All the other questions in the app go fine. I have also run a profile and confirmed that the app is actually running the query which I hope (when I get the code which is run by the programmer show app and run it in SSMS , It takes less than 2 seconds).
Long time running questions do not come in the app.
What's going on?
String result = dbHelper.GetTypedDataTable (dtMyProjects, "sp_get_DashboardPMMyProjects", MyUttivity.DW Connection, New String [] {"'+" + ShortNTID + "' '}); Static public string GetTypedDataTable (DataTable DT, string SSPN, string connection name, string [] arraypalmators) {if (connectionName == "default") {Setup Connection (SSPN, "sqlConn.ConnectionString", "SP"); } Other {Setup Connection (SSP, Connection Name, "SP"); } CmdSELECT.CommandText + = "" + arrayParameters [0]. Ostring (); Int countParameters = arrayParameters.Length; For (int i = 1; i & lt; countParameters; i ++) {cmdSELECT.CommandText + = "," + array parameter [i]. Ostring (); } Filtatable (DT) returns; } Private static zero SetupConnection (string SSPN, string connection name, string sqlType) {//sqlConn.ConnectionString = (string) (configurationAppSettings.GetValue ("sqlConn.ConnectionString", typef (string))); SqlConn.ConnectionString = ((string) (configurationAppSettings.GetValue (connectionName, typeof (string))); DaHlpr.SelectCommand = cmdSELECT; CmdSELECT.Connection = sqlConn; If (sqlType == "SP") {cmdSELECT.CommandText = "EXEC" + sSPName; } And {cmdSELECT.CommandText = sSPName; }} Private Static String FillDataTable (DataTable dt) {try {daHlpr.SelectCommand.CommandTimeout = 60; Dahlpr Fill (0, 1000000000, DT); } Hold (Exception pre) {return ex.Message.ToString (); } Return dt.Rows.Count.ToString (); // Returning the count of rows in the table}
Two seconds is a lot Long time these days, there should be a decent amount of essential processing.
If you are using a stored procedure, you may have to disable the sniffing of the parameter
Actually, on SP execution, immediately change each SP parameter into an immediate variable Archive. Here's a link with more details:
Also, though it can be obvious, sometimes it's easy to forget. These problems can be foiled on Dev Machine Reboot, SQL Server Service Restart, or SQL Server Machine Reboot.
Comments
Post a Comment