Is there anything in the stored procedure that executes before calling the SQLCLR function?
In general, if you want to see what is happening in real-time, you have three options:
- SQL Server Profiler
- Extended Events
- Database Audits
The first two will let you watch events as they happen, and you can see what the start times and duration of each statement are.
The third option, Audits, let you easily capture events to a log file that you can view via a system TVF. You can trap SCHEMA OBJECT ACCESS and then filter at the Server Audit level (required for either Database Audit Specifications or Server Audit Specifications) for objects having the name of either the stored procedure or the function. You won't get to see the level of detail that you get with the first two options, nor can you see a breakdown of individual statements within a stored procedure, but it is a fairly light-weight mechanism for capturing these events if they are happening when you aren't there to watch via the first two options.
That said, if you are seeing delays with a web service call, and if that web service call is being executed by more than 2 sessions concurrently, and if those concurrent web service calls are to the same URI, then you are running into the default max connections per URI limit, which is 2. When this limit is reached, all additional calls to that URI are on hold until one of the 2 calls completes. You can increase this max connections per URI by setting the ConnectionLimit property of the ServicePoint
class, which itself is a property of HttpWebRequest
(and any other *WebRequest):
_MyHttpWebRequest.ServicePoint.ConnectionLimit = 10;