Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server Profiler - Why are some calls RPC:Completed and Some Calls SQL:BatchCompleted

I will be the first to admit that I often get confused when I use SQL Server profiler.

Having said that, I decided to fire it up to see the SQL that was being generated by experimenting with the Include method of a Db Set. I was going through the music store example where there are Albums, Artists, and Genres.

One thing I noticed was that some calls had an event class of SQL:BatchCompleted while others had an event class of RPC:Completed. It seemed like the lazy load calls were being traced under the RPC event class.

What is the difference was between these two event classes and why does lazy loading result in an event class of RPC:Completed?

like image 499
ek_ny Avatar asked Oct 26 '12 16:10

ek_ny


People also ask

What is RPC completed in SQL profiler?

RPC:Completed means stored proc has completed. It could be that EF executes SQL code dynamically using sp_executesql so you get RPC:Completed.

What is RPC event in SQL Server?

An RPC call means that the stored procedure was called from outside the SQL Server instance space. For example, if you have a web application or windows application which creates a SQL connection string and then makes a call to execute the SP.

Does running SQL profiler affect performance?

Yes, SQL Server Profiler does affect performance. When you trace using the GUI, all events are synchronously processed and filtered, so factors such as server load, network latency, which events you collect, and even where the collected events are stored, all contribute to overhead.


1 Answers

BatchCompleted means TSQL code (e.g. selects) have completed. RPC:Completed means stored proc has completed. It could be that EF executes SQL code dinamically using sp_executesql so you get RPC:Completed.

like image 104
OzrenTkalcecKrznaric Avatar answered Nov 03 '22 17:11

OzrenTkalcecKrznaric