[Last Call] Learn how to a build a cloud-first strategyRegister Now


trigger on a dynamic management view

Posted on 2009-02-18
Medium Priority
Last Modified: 2012-05-06
can you put a trigger on a DMV?
Question by:david_32
  • 2
LVL 22

Expert Comment

ID: 23676948
Even if you could put a trigger on a DMV I don't think it would ever fire because they aren't updateable. DMVs are purely derived data.

What are you tring to achieve? Maybe a DDL trigger will do the job:

Author Comment

ID: 23677570
I want to see how long an entry stays in the dm_exec_cached_plans DMV. Effectively seeing how long a plan is cached for
LVL 51

Accepted Solution

Mark Wills earned 2000 total points
ID: 23677981
Cannot do it, but can run various queries on   sys.dm_exec_query_stats

There is a usecount in there and that is what you are probably looking for.

There can be a lot of reasons why a query plan remains or is flushed from memory, so "how long" is not really going to do much for you. More so, high query plan reuse is important.

Now, from your other thread about memory pressure, then it alone can cause low plan re-use, so looking at that measure without considering some of the others is going to be guesses at best...

So, back to Perfmon. This time, want to start moinitoring (or add in the extra objects) SQL Server:SQL Statistics.

The idea is to compare batch requests to initial compilations. An initial compilation occurs when a plan is not found in cache. Ideally you have high plan reuse, > 80% (the higher the better, but I tend to stick with a "real life 80/20 rule" I think MS says > 90 %).

Initial Compilations = SQL Compilations/sec  SQL Re-Compilations/sec
Plan reuse = (Batch requests/sec  Initial Compilations/sec) / Batch requests/sec

Memory pressure can result in reduced plan reuse - remember that other thread as to what type of measure we need to check for memory pressure ?


Author Closing Comment

ID: 31548583

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question