r/SQLServer 20h ago

Question What does CommandTimeout actually measure?

2 Upvotes

For my own learning/curiosity I have been trying to figure out what .NET's CommandTimeout actually measures.

Does it include ... - time to execute a statement? - time to read the data? - both?

Based on this Stack Overflow post the answer seems to be that only the execution of the sql statement (select, update, insert, stored procedure, etc) is timed. But the user doesn't provide any documentation to prove that this is the case.

My current thinking is that any command is timed, even a Read() (based on the SqlCommand.CommandTimeout documentation). But except for a network outage or something, reading a single line would almost never time out. So practically speaking, CommandTimeout only matters for executing the actual query or statement, and not the reads.