Is there any way for me to see the top clients of my sql server?
I want to figure who is executing so many queries on my server. Ultimately I would love to see the application name(like in sql profiler) and IP/name of the server, but even knowing which web server the queries come from would help alot.
Remote Client | Database | Executions/min
--------------------------------------------------
XXXX | FooDb | 88.00
--------------------------------------------------
XXXX | BarDb | 43.00
--------------------------------------------------
Instead of XXXX it could be – remote server name, IP, ApplicationName (like in SQL Profiler) – any of these.
I think something like this is possible in SQL Profiler, but I cannot run it because this is production environment, and the performance is already bad
Best Answer
Not sure it is possible to get exactly what you want. It probably depends on the setup of the application calling your database, how its connections are pooled etc. But the following will give you the number of current connections, plus their IP and application names:
Unfortunately this doesn't indicate the activity on the connections. I don't know if the dmv's will be able to return you a history of all the calls broken down by connection/session, which sounds like what you want. This is exactly the sort of thing extended events are for, so in the absence using extended events, you may be stuck.
Coming from an execution side, you could do it for all queries in the last minute using something like the below:
Unfortunately this does not show connection information. What you are really after is a combination of the above two, all connections in the past minute and how many executions they performed. Unfortunately the dmv
sys.dm_exec_connections
only lists the most recent sql query, otherwise it would be a good candidate.If you really needed this information, you could store both the above queries in tables, running inserts into the tables every minute using a job that is scheduled to run every minute. You could then analyse both tables and make some assumptions about what is calling the procedures.
There may be a way to provide all historic executions from a session/connection using dmv's which I don't know, hopefully this will put you on the right track.