views:

227

answers:

5

I have been told that SQL Profiler makes changes to the MSDB when it is run. Is this true and if so what changes does it make?

MORE INFO

The reason I ask is that we have a DBA who wants us to range a change request when we run the profiler on a live server. Her argument is that it makes changes to the DB's which should be change controlled.

A: 

That's not the case as far as I'm aware (other than the trivial change noted by others).

What changes are you referring to?

Mitch Wheat
+1  A: 

The only ones I know happen when you schedule a trace to gather periodic information - a job is added.

Raj More
You mean a SQL Agent job? A trace does not require a SQL Agent job to run.
Philip Kelley
@Philip Kelly: I did not say that a job is automatically created. I said that when you schedule a trace, a job will be created.
Raj More
Do you mean a specific SQL Agent job, or a background job/task?
Philip Kelley
As a part of regular work, my DBA scheduled profiler runs. He created a SQL Server job for that.
Raj More
Got it -- your DBA created a job that creates the trace. (I've done that too.) These comments make that clear, so I'll reverse my downvote.
Philip Kelley
SO says "Vote too old to be changed, unless this answer is edited". I didn't know it worked that way. So, if you update your answer, I'll update my vote.
Philip Kelley
i just edited the text
Raj More
+1  A: 

When you use profiler, it actually creates a Trace in the background. SQL server comes with a default stored procedure that creates a trace. Everything you need to know about what is changed in the DB is shown in that stored procedure.

I posted it on my blog here: http://codingathome.blogspot.com/2009/04/create-sql-trace-and-read-it-using-sql.html

djangofan
The blog post does not state any changes that are applied to the MSDB database?
John Sansom
thats because there really arent any.
djangofan
A: 

Nothing I have ever read, heard, or seen says that SQL Profiler or anything it does or uses has any impact on the MSDB database. (SQL Profiler is, essentially, a GUI wrapped around the trace routines.) It is of course possible to configure a specific setup/implementation to do, well, anything, and perhaps that's what someone is thinking of.

This sounds like a kind of "urban legend". I recommend that you challenge it -- get the people who claim it to be true to provide proof.

Philip Kelley
+3  A: 

Starting a trace adds a row into msdb.sys.traces, stopping the trace removes the row. However msdb.sys.traces is a view over an internal table valued function and is not backed by any physical storage. To prove this, set msdb to read_only, start a trace, observer the new row in msdb.sys.traces, stop the trace, remember to turn msdb back read_write. Since a trace can be started in the Profiler event when msdb is read only it is clear that normally there is no write into msdb that can occur.

Now before you go and grin to your dba, she is actually right. Profiler traces can pose a significant stress on a live system because the traced events must block until they can generate the trace record. Live, busy, systems may experience blocking on resources of type SQLTRACE_BUFFER_FLUSH, SQLTRACE_LOCK, TRACEWRITE and other. Live traces (profiler) are usualy worse, file traces (sp_trace_create) are better, but still can cause issues. So starting new traces should definetly something that the DBa should be informed about and very carefully considered.

Remus Rusanu