![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hello people. I have a strange behaviour with a stored procedure. Using management studio procedure executes in 1 second. Using a .net application (VS 2005) with sqlclient same procedure get me a timeout execution.. Any help??? Best Robson |
#3
| |||
| |||
|
|
Sounds like parameter sniffing issue. Have a look at these: http://www.microsoft.com/technet/pro...05/recomp.mspx http://blogs.msdn.com/queryoptteam/a...31/565991.aspx http://omnibuzz-sql.blogspot.com/200...rocedures.html -- Andrew J. Kelly SQL MVP Solid Quality Mentors "Robson Luiz" <robsonbr_2004 (AT) yahoo (DOT) com.br> wrote in message news:%23mBc09ZPIHA.280 (AT) TK2MSFTNGP03 (DOT) phx.gbl... Hello people. I have a strange behaviour with a stored procedure. Using management studio procedure executes in 1 second. Using a .net application (VS 2005) with sqlclient same procedure get me a timeout execution.. Any help??? Best Robson |
#4
| |||
| |||
|
|
But it still strange.. Same procedure with same parameters executes in 1 sec in sql management studio and get me timeout when executed in a .net application using sqlclient. but if i recompile the SP in SSMS both cases work well. But after a time the problem repeats.. I see SSMS is not sensitive to query plan as sqlclient is. Robson Robson "Andrew J. Kelly" <sqlmvpnooospam (AT) shadhawk (DOT) com> wrote in message news:OR2OQMbPIHA.5164 (AT) TK2MSFTNGP03 (DOT) phx.gbl... Sounds like parameter sniffing issue. Have a look at these: http://www.microsoft.com/technet/pro...05/recomp.mspx http://blogs.msdn.com/queryoptteam/a...31/565991.aspx http://omnibuzz-sql.blogspot.com/200...rocedures.html -- Andrew J. Kelly SQL MVP Solid Quality Mentors "Robson Luiz" <robsonbr_2004 (AT) yahoo (DOT) com.br> wrote in message news:%23mBc09ZPIHA.280 (AT) TK2MSFTNGP03 (DOT) phx.gbl... Hello people. I have a strange behaviour with a stored procedure. Using management studio procedure executes in 1 second. Using a .net application (VS 2005) with sqlclient same procedure get me a timeout execution.. Any help??? Best Robson |
#5
| |||
| |||
|
|
Hello people. I have a strange behaviour with a stored procedure. Using management studio procedure executes in 1 second. Using a .net application (VS 2005) with sqlclient same procedure get me a timeout execution.. Any help??? Best Robson |
#6
| |||
| |||
|
|
Exactly how are you calling it in SSMS? Can you show the exact code? In .net you are defining the datatypes and in SSMS it may be guessing. Plus it will be an RPC call in .net vs. a Batch in SSMS and will get two plans which may or may not be the same. -- Andrew J. Kelly SQL MVP Solid Quality Mentors "Robson Luiz" <robsonbr_2004 (AT) yahoo (DOT) com.br> wrote in message news:e2Ohe0cPIHA.4272 (AT) TK2MSFTNGP06 (DOT) phx.gbl... But it still strange.. Same procedure with same parameters executes in 1 sec in sql management studio and get me timeout when executed in a .net application using sqlclient. but if i recompile the SP in SSMS both cases work well. But after a time the problem repeats.. I see SSMS is not sensitive to query plan as sqlclient is. Robson Robson "Andrew J. Kelly" <sqlmvpnooospam (AT) shadhawk (DOT) com> wrote in message news:OR2OQMbPIHA.5164 (AT) TK2MSFTNGP03 (DOT) phx.gbl... Sounds like parameter sniffing issue. Have a look at these: http://www.microsoft.com/technet/pro...05/recomp.mspx http://blogs.msdn.com/queryoptteam/a...31/565991.aspx http://omnibuzz-sql.blogspot.com/200...rocedures.html -- Andrew J. Kelly SQL MVP Solid Quality Mentors "Robson Luiz" <robsonbr_2004 (AT) yahoo (DOT) com.br> wrote in message news:%23mBc09ZPIHA.280 (AT) TK2MSFTNGP03 (DOT) phx.gbl... Hello people. I have a strange behaviour with a stored procedure. Using management studio procedure executes in 1 second. Using a .net application (VS 2005) with sqlclient same procedure get me a timeout execution.. Any help??? Best Robson |
#7
| |||
| |||
|
|
Procedure call in SSMS exec dbo.mapa_separacao_pesquisar_ext @empresa_id=1,@unidade_negocio_id='2.001.02',@data _inicial='2007/10/11',@data_final='2007/12/11' Executes in 1 second in .net app. Dim conn As New SqlConnection conn.ConnectionString = "Data Source=server1;Initial Catalog=varuna70;Integrated Security=True" Dim cmd As New SqlCommand Dim par1 As SqlParameter Dim par2 As SqlParameter Dim par3 As SqlParameter Dim par4 As SqlParameter Dim sqla As New SqlDataAdapter Dim ds As New DataSet cmd.CommandType = CommandType.StoredProcedure cmd.CommandText = "mapa_separacao_pesquisar_ext" par1 = New SqlParameter("@empresa_id", 1) cmd.Parameters.Add(par1) par2 = New SqlParameter("@unidade_negocio_id", "2.001.02") cmd.Parameters.Add(par2) par3 = New SqlParameter("@data_inicial", "2007/11/11") cmd.Parameters.Add(par3) par4 = New SqlParameter("@data_final", "2007/12/11") cmd.Parameters.Add(par4) cmd.Connection = conn sqla.SelectCommand = cmd sqla.Fill(ds) -- timeout Me.DataGridView1.DataSource = ds.Tables(0) Me.DataGridView1.Refresh() "Andrew J. Kelly" <sqlmvpnooospam (AT) shadhawk (DOT) com> wrote in message news:uCKTk9cPIHA.4752 (AT) TK2MSFTNGP05 (DOT) phx.gbl... Exactly how are you calling it in SSMS? Can you show the exact code? In .net you are defining the datatypes and in SSMS it may be guessing. Plus it will be an RPC call in .net vs. a Batch in SSMS and will get two plans which may or may not be the same. -- Andrew J. Kelly SQL MVP Solid Quality Mentors "Robson Luiz" <robsonbr_2004 (AT) yahoo (DOT) com.br> wrote in message news:e2Ohe0cPIHA.4272 (AT) TK2MSFTNGP06 (DOT) phx.gbl... But it still strange.. Same procedure with same parameters executes in 1 sec in sql management studio and get me timeout when executed in a .net application using sqlclient. but if i recompile the SP in SSMS both cases work well. But after a time the problem repeats.. I see SSMS is not sensitive to query plan as sqlclient is. Robson Robson "Andrew J. Kelly" <sqlmvpnooospam (AT) shadhawk (DOT) com> wrote in message news:OR2OQMbPIHA.5164 (AT) TK2MSFTNGP03 (DOT) phx.gbl... Sounds like parameter sniffing issue. Have a look at these: http://www.microsoft.com/technet/pro...05/recomp.mspx http://blogs.msdn.com/queryoptteam/a...31/565991.aspx http://omnibuzz-sql.blogspot.com/200...rocedures.html -- Andrew J. Kelly SQL MVP Solid Quality Mentors "Robson Luiz" <robsonbr_2004 (AT) yahoo (DOT) com.br> wrote in message news:%23mBc09ZPIHA.280 (AT) TK2MSFTNGP03 (DOT) phx.gbl... Hello people. I have a strange behaviour with a stored procedure. Using management studio procedure executes in 1 second. Using a .net application (VS 2005) with sqlclient same procedure get me a timeout execution.. Any help??? Best Robson |
#8
| |||
| |||
|
|
Have you tried updating the statistic on the table(s) that the procedure is using? I have seen this before with out of data statistics. What I feel is happening is that it is using two seperate execution plans... http://msdn2.microsoft.com/en-us/library/ms187348.aspx -- /* Warren Brunk - MCITP,MCTS,MCDBA www.techintsolutions.com */ "Robson Luiz" <robsonbr_2004 (AT) yahoo (DOT) com.br> wrote in message news:ursNXmdPIHA.4808 (AT) TK2MSFTNGP05 (DOT) phx.gbl... Procedure call in SSMS exec dbo.mapa_separacao_pesquisar_ext @empresa_id=1,@unidade_negocio_id='2.001.02',@data _inicial='2007/10/11',@data_final='2007/12/11' Executes in 1 second in .net app. Dim conn As New SqlConnection conn.ConnectionString = "Data Source=server1;Initial Catalog=varuna70;Integrated Security=True" Dim cmd As New SqlCommand Dim par1 As SqlParameter Dim par2 As SqlParameter Dim par3 As SqlParameter Dim par4 As SqlParameter Dim sqla As New SqlDataAdapter Dim ds As New DataSet cmd.CommandType = CommandType.StoredProcedure cmd.CommandText = "mapa_separacao_pesquisar_ext" par1 = New SqlParameter("@empresa_id", 1) cmd.Parameters.Add(par1) par2 = New SqlParameter("@unidade_negocio_id", "2.001.02") cmd.Parameters.Add(par2) par3 = New SqlParameter("@data_inicial", "2007/11/11") cmd.Parameters.Add(par3) par4 = New SqlParameter("@data_final", "2007/12/11") cmd.Parameters.Add(par4) cmd.Connection = conn sqla.SelectCommand = cmd sqla.Fill(ds) -- timeout Me.DataGridView1.DataSource = ds.Tables(0) Me.DataGridView1.Refresh() "Andrew J. Kelly" <sqlmvpnooospam (AT) shadhawk (DOT) com> wrote in message news:uCKTk9cPIHA.4752 (AT) TK2MSFTNGP05 (DOT) phx.gbl... Exactly how are you calling it in SSMS? Can you show the exact code? In .net you are defining the datatypes and in SSMS it may be guessing. Plus it will be an RPC call in .net vs. a Batch in SSMS and will get two plans which may or may not be the same. -- Andrew J. Kelly SQL MVP Solid Quality Mentors "Robson Luiz" <robsonbr_2004 (AT) yahoo (DOT) com.br> wrote in message news:e2Ohe0cPIHA.4272 (AT) TK2MSFTNGP06 (DOT) phx.gbl... But it still strange.. Same procedure with same parameters executes in 1 sec in sql management studio and get me timeout when executed in a .net application using sqlclient. but if i recompile the SP in SSMS both cases work well. But after a time the problem repeats.. I see SSMS is not sensitive to query plan as sqlclient is. Robson Robson "Andrew J. Kelly" <sqlmvpnooospam (AT) shadhawk (DOT) com> wrote in message news:OR2OQMbPIHA.5164 (AT) TK2MSFTNGP03 (DOT) phx.gbl... Sounds like parameter sniffing issue. Have a look at these: http://www.microsoft.com/technet/pro...05/recomp.mspx http://blogs.msdn.com/queryoptteam/a...31/565991.aspx http://omnibuzz-sql.blogspot.com/200...rocedures.html -- Andrew J. Kelly SQL MVP Solid Quality Mentors "Robson Luiz" <robsonbr_2004 (AT) yahoo (DOT) com.br> wrote in message news:%23mBc09ZPIHA.280 (AT) TK2MSFTNGP03 (DOT) phx.gbl... Hello people. I have a strange behaviour with a stored procedure. Using management studio procedure executes in 1 second. Using a .net application (VS 2005) with sqlclient same procedure get me a timeout execution.. Any help??? Best Robson |
#9
| |||
| |||
|
|
Procedure call in SSMS exec dbo.mapa_separacao_pesquisar_ext @empresa_id=1,@unidade_negocio_id='2.001.02',@data _inicial='2007/10/11',@data_final='2007/12/11' Executes in 1 second in .net app. Dim conn As New SqlConnection conn.ConnectionString = "Data Source=server1;Initial Catalog=varuna70;Integrated Security=True" Dim cmd As New SqlCommand Dim par1 As SqlParameter Dim par2 As SqlParameter Dim par3 As SqlParameter Dim par4 As SqlParameter Dim sqla As New SqlDataAdapter Dim ds As New DataSet cmd.CommandType = CommandType.StoredProcedure cmd.CommandText = "mapa_separacao_pesquisar_ext" par1 = New SqlParameter("@empresa_id", 1) cmd.Parameters.Add(par1) par2 = New SqlParameter("@unidade_negocio_id", "2.001.02") cmd.Parameters.Add(par2) par3 = New SqlParameter("@data_inicial", "2007/11/11") cmd.Parameters.Add(par3) par4 = New SqlParameter("@data_final", "2007/12/11") cmd.Parameters.Add(par4) cmd.Connection = conn sqla.SelectCommand = cmd sqla.Fill(ds) -- timeout Me.DataGridView1.DataSource = ds.Tables(0) Me.DataGridView1.Refresh() "Andrew J. Kelly" <sqlmvpnooospam (AT) shadhawk (DOT) com> wrote in message news:uCKTk9cPIHA.4752 (AT) TK2MSFTNGP05 (DOT) phx.gbl... Exactly how are you calling it in SSMS? Can you show the exact code? In .net you are defining the datatypes and in SSMS it may be guessing. Plus it will be an RPC call in .net vs. a Batch in SSMS and will get two plans which may or may not be the same. -- Andrew J. Kelly SQL MVP Solid Quality Mentors "Robson Luiz" <robsonbr_2004 (AT) yahoo (DOT) com.br> wrote in message news:e2Ohe0cPIHA.4272 (AT) TK2MSFTNGP06 (DOT) phx.gbl... But it still strange.. Same procedure with same parameters executes in 1 sec in sql management studio and get me timeout when executed in a .net application using sqlclient. but if i recompile the SP in SSMS both cases work well. But after a time the problem repeats.. I see SSMS is not sensitive to query plan as sqlclient is. Robson Robson "Andrew J. Kelly" <sqlmvpnooospam (AT) shadhawk (DOT) com> wrote in message news:OR2OQMbPIHA.5164 (AT) TK2MSFTNGP03 (DOT) phx.gbl... Sounds like parameter sniffing issue. Have a look at these: http://www.microsoft.com/technet/pro...05/recomp.mspx http://blogs.msdn.com/queryoptteam/a...31/565991.aspx http://omnibuzz-sql.blogspot.com/200...rocedures.html -- Andrew J. Kelly SQL MVP Solid Quality Mentors "Robson Luiz" <robsonbr_2004 (AT) yahoo (DOT) com.br> wrote in message news:%23mBc09ZPIHA.280 (AT) TK2MSFTNGP03 (DOT) phx.gbl... Hello people. I have a strange behaviour with a stored procedure. Using management studio procedure executes in 1 second. Using a .net application (VS 2005) with sqlclient same procedure get me a timeout execution.. Any help??? Best Robson |
#10
| |||
| |||
|
|
In fact i noted that behaviour after upgrade a database from 2000 to 2005. Performance is some cases is poor. "Warren Brunk" <wbrunk (AT) techintsolutions (DOT) com> wrote in message news:7052533E-0A8B-4227-87E7-0AE167157558 (AT) microsoft (DOT) com... Have you tried updating the statistic on the table(s) that the procedure is using? I have seen this before with out of data statistics. What I feel is happening is that it is using two seperate execution plans... http://msdn2.microsoft.com/en-us/library/ms187348.aspx -- /* Warren Brunk - MCITP,MCTS,MCDBA www.techintsolutions.com */ "Robson Luiz" <robsonbr_2004 (AT) yahoo (DOT) com.br> wrote in message news:ursNXmdPIHA.4808 (AT) TK2MSFTNGP05 (DOT) phx.gbl... Procedure call in SSMS exec dbo.mapa_separacao_pesquisar_ext @empresa_id=1,@unidade_negocio_id='2.001.02',@data _inicial='2007/10/11',@data_final='2007/12/11' Executes in 1 second in .net app. Dim conn As New SqlConnection conn.ConnectionString = "Data Source=server1;Initial Catalog=varuna70;Integrated Security=True" Dim cmd As New SqlCommand Dim par1 As SqlParameter Dim par2 As SqlParameter Dim par3 As SqlParameter Dim par4 As SqlParameter Dim sqla As New SqlDataAdapter Dim ds As New DataSet cmd.CommandType = CommandType.StoredProcedure cmd.CommandText = "mapa_separacao_pesquisar_ext" par1 = New SqlParameter("@empresa_id", 1) cmd.Parameters.Add(par1) par2 = New SqlParameter("@unidade_negocio_id", "2.001.02") cmd.Parameters.Add(par2) par3 = New SqlParameter("@data_inicial", "2007/11/11") cmd.Parameters.Add(par3) par4 = New SqlParameter("@data_final", "2007/12/11") cmd.Parameters.Add(par4) cmd.Connection = conn sqla.SelectCommand = cmd sqla.Fill(ds) -- timeout Me.DataGridView1.DataSource = ds.Tables(0) Me.DataGridView1.Refresh() "Andrew J. Kelly" <sqlmvpnooospam (AT) shadhawk (DOT) com> wrote in message news:uCKTk9cPIHA.4752 (AT) TK2MSFTNGP05 (DOT) phx.gbl... Exactly how are you calling it in SSMS? Can you show the exact code? In .net you are defining the datatypes and in SSMS it may be guessing. Plus it will be an RPC call in .net vs. a Batch in SSMS and will get two plans which may or may not be the same. -- Andrew J. Kelly SQL MVP Solid Quality Mentors "Robson Luiz" <robsonbr_2004 (AT) yahoo (DOT) com.br> wrote in message news:e2Ohe0cPIHA.4272 (AT) TK2MSFTNGP06 (DOT) phx.gbl... But it still strange.. Same procedure with same parameters executes in 1 sec in sql management studio and get me timeout when executed in a .net application using sqlclient. but if i recompile the SP in SSMS both cases work well. But after a time the problem repeats.. I see SSMS is not sensitive to query plan as sqlclient is. Robson Robson "Andrew J. Kelly" <sqlmvpnooospam (AT) shadhawk (DOT) com> wrote in message news:OR2OQMbPIHA.5164 (AT) TK2MSFTNGP03 (DOT) phx.gbl... Sounds like parameter sniffing issue. Have a look at these: http://www.microsoft.com/technet/pro...05/recomp.mspx http://blogs.msdn.com/queryoptteam/a...31/565991.aspx http://omnibuzz-sql.blogspot.com/200...rocedures.html -- Andrew J. Kelly SQL MVP Solid Quality Mentors "Robson Luiz" <robsonbr_2004 (AT) yahoo (DOT) com.br> wrote in message news:%23mBc09ZPIHA.280 (AT) TK2MSFTNGP03 (DOT) phx.gbl... Hello people. I have a strange behaviour with a stored procedure. Using management studio procedure executes in 1 second. Using a .net application (VS 2005) with sqlclient same procedure get me a timeout execution.. Any help??? Best Robson |
![]() |
| Thread Tools | |
| Display Modes | |
| |