F
fniles
We are using SQL Server 2005 and VB.NET 2008.
We have a view that is called by the application every minute.
The view is doing a SELECT of 2 more views and a table.
When I run the view on the SQL Server Management Studio, it runs for 2
seconds.
Most of the time when the view is run from the VB.NET program it runs
as fast.
But, about once or twice a day in the program the view will timed out
(error "Timeout expired. The timeout period elapsed prior to
completion of the operation or the server is not responding.), even
after I set the command time out to 45 seconds (which is a lot longer
than the 2 seconds it takes to run it on the SSMS).
Why would the same SELECT view runs fast most of the time, but very
slow once or twice a day ?
SQL Server machine has 8 processors of 2993 Mhz each and 32 MB of
RAM.
Right now the available physical memory there is 18.48 GB, and SQL
Server is using 9-50% of CPU and 11,358,080K of RAM. It has 32
database, but only 5 are very active databases.
Dim m_daSQL As SqlClient.SqlDataAdapter
Dim m_dsSQL As DataSet
Dim m_cmdSQL As SqlClient.SqlCommand
m_cmdSQL = New SqlClient.SqlCommand
With m_cmdSQL
.Connection = adoCon
.CommandText = sSQL
End With
m_daSQL = New SqlClient.SqlDataAdapter
m_dsSQL = New DataSet
m_daSQL.SelectCommand = m_cmdSQL
m_cmdSQL.CommandTimeout = iTimeOut
m_daSQL.Fill(m_dsSQL) ----->>>> Timed out here
This is the stack of where the view timed out in the program:
System.Data.SqlClient.SqlConnection.OnError(SqlException exception,
Boolean breakConnection)
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException
exception, Boolean breakConnection)
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject
stateObj)
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior,
SqlCommand cmdHandler, SqlDataReader dataStream,
BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject
stateObj)
System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
System.Data.SqlClient.SqlDataReader.get_MetaData()
System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader
ds, RunBehavior runBehavior, String resetOptionsString)
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean
async)
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String
method, DbAsyncResult result)
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String
method)
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior
behavior, String method)
System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior
behavior)
System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior
behavior)
System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset,
DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String
srcTable, IDbCommand command, CommandBehavior behavior)
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior)
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
We have a view that is called by the application every minute.
The view is doing a SELECT of 2 more views and a table.
When I run the view on the SQL Server Management Studio, it runs for 2
seconds.
Most of the time when the view is run from the VB.NET program it runs
as fast.
But, about once or twice a day in the program the view will timed out
(error "Timeout expired. The timeout period elapsed prior to
completion of the operation or the server is not responding.), even
after I set the command time out to 45 seconds (which is a lot longer
than the 2 seconds it takes to run it on the SSMS).
Why would the same SELECT view runs fast most of the time, but very
slow once or twice a day ?
SQL Server machine has 8 processors of 2993 Mhz each and 32 MB of
RAM.
Right now the available physical memory there is 18.48 GB, and SQL
Server is using 9-50% of CPU and 11,358,080K of RAM. It has 32
database, but only 5 are very active databases.
Dim m_daSQL As SqlClient.SqlDataAdapter
Dim m_dsSQL As DataSet
Dim m_cmdSQL As SqlClient.SqlCommand
m_cmdSQL = New SqlClient.SqlCommand
With m_cmdSQL
.Connection = adoCon
.CommandText = sSQL
End With
m_daSQL = New SqlClient.SqlDataAdapter
m_dsSQL = New DataSet
m_daSQL.SelectCommand = m_cmdSQL
m_cmdSQL.CommandTimeout = iTimeOut
m_daSQL.Fill(m_dsSQL) ----->>>> Timed out here
This is the stack of where the view timed out in the program:
System.Data.SqlClient.SqlConnection.OnError(SqlException exception,
Boolean breakConnection)
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException
exception, Boolean breakConnection)
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject
stateObj)
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior,
SqlCommand cmdHandler, SqlDataReader dataStream,
BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject
stateObj)
System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
System.Data.SqlClient.SqlDataReader.get_MetaData()
System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader
ds, RunBehavior runBehavior, String resetOptionsString)
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean
async)
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String
method, DbAsyncResult result)
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String
method)
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior
behavior, String method)
System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior
behavior)
System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior
behavior)
System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset,
DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String
srcTable, IDbCommand command, CommandBehavior behavior)
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior)
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)