Search code examples
sql-servert-sqlbandwidth

How do I measure the cost of a T-SQL query on the wire?


How can I calculate the size of a T-SQL query in bytes transfered across the network?

I know I can approximate it by examining data types of columns (varchars are an interesting twist though), but are there tools that'll give me the number of bytes (including and excluding TCP/IP headers) used up while transferring the query and its results to and from the SQL Server?


Solution

  • If you are using the Microsoft Sql Server Management Studio, you can toggle the "Include Client Statistics" from the "Query" menu.

    You will get some network statistics like

    • Bytes sent from client
    • Bytes received from server
    • TDS packets received from server

    You can also leave that option on and get an average of all query executions.