T-sql – Is a single batch request equivalent to a single tsql request

monitoringperformancet-sql

I'm looking into some performance metrics and every recommendation includes monitoring Batch Requests/sec. But, maybe a silly question, does a singe batch request correspond to exactly one tsql statement? Say it contains exactly one select or one update, etc. So, for example, a stored procedure with 3 selects and 2 inserts triggers 5 batch requests. Or, as I think, a batch request can include for example a full stored procedure, a function, several select/update/insert statements, etc.

All I can find is similar to these descriptions:

  • TechNet Number of Transact-SQL command batches received per second. This statistic is affected by all constraints (such as I/O, number of users, cache size, complexity of requests, and so on). High batch requests mean good throughput.
  • Understanding how SQL Server executes a query Batch Request This request type contains just T-SQL text for a batch to be executed. This type of requests do not have parameters, but obviously the T-SQL batch itself can contain local variables declarations. This is the type of request SqlClient sends if you invoke any of the SqlCommand.ExecuteReader(), ExecuteNonQuery(), ExecuteScalar(), ExecuteXmlReader() (or they respective asyncronous equivalents) on a SqlCommand object with an empty Parameters list. If you monitor with SQL Profiler you will see an SQL:BatchStarting Event Class

Best Answer

As per the comment, then no - it's not a single statement. A batch can cover multiple individual T-SQL statements in a single batch.