May 24, 2004 at 1:34 pm
Due to the high number of poorly performing queries that are run on my servers on a daily basis I insituted the Query Governor today. It works great and has already annoyed many an ad-hoc report user by preventing them from killing the servers.
I've changed the sysmessage for this event (8649) so that it writes an event to the log so that I know this has happened, however the problem is that it does not give me any other information regarding the query that was trying to be executed.
Does anyone know of a way that I could somehow gather this information and include it in the error message, I've tried to find something further, but I think this might go too far into the SQL internals to actually get all that I need.
Any thoughts?
Thanks
May 24, 2004 at 5:20 pm
May 25, 2004 at 4:04 am
You could set up a trace with SQL Profiler (or sp_tracecreate/sp_trace_setevent) for the Errors and Warning:Exception class, selecting at least Error, SPID, LoginName, NTUserName, DBUserName columns and maybe filtering for Error 8649. That will at least give you the culprit session/user.
You could also trace SQL:StmtStarting (or similar) to see the submitted query.
Salvor
May 25, 2004 at 5:12 am
The problem is that I have users writing ad-hoc queries on the server and I am not in a position to be able to prevent that from happening, I am trying to prevent a single user from killing the server and stopping other users from getting the information they require.
May 25, 2004 at 1:16 pm
I wonder if you could use @@spid and dbcc input_buffer to get what you need.
Steve
May 25, 2004 at 1:27 pm
The problem is that the governor uses is not called using SQL that I have been able to trap so I don't believe that I can change the way that the error is called to include further parameters than currently are passed.
May 26, 2004 at 1:47 am
I set up the simple trace session I described in my previous post, then ran this batch within QA:
SET QUERY_GOVERNOR_COST_LIMIT 1
select o.orderid,p.productid
from orders o
cross join [order details] p
This is the trace collected:
EventClass | TextData | NTUserName | ClientProcessID | ApplicationName | LoginName | SPID | StartTime | Error |
TraceStart | 2004-05-26 08:24:14.783 | |||||||
SQL:StmtStarting | SET QUERY_GOVERNOR_COST_LIMIT 1 | pippo | 2088 | SQL Query Analyzer | pippo | 51 | 2004-05-26 08:24:20.793 | |
SQL:StmtStarting | select o.orderid,p.productid from orders o cross join [order details] p | pippo | 2088 | SQL Query Analyzer | pippo | 51 | 2004-05-26 08:24:20.793 | |
Exception | Error: 8649, Severity: 17, State: 1 | pippo | 2088 | SQL Query Analyzer | pippo | 51 | 2004-05-26 08:24:20.793 | 8649 |
As you can see, the SQL statement is trapped even if it's not executed.
Salvor
May 26, 2004 at 5:37 am
Thanks Salvor, I was looking to try and avoid running a trace if I could, but it looks as though thats going to be the only way to get the information.
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply