Does this sound like a good place to enable "Optimize for ad-hoc workloads?"

  • I recently ran the "Server Dashboard" report on a new server here. Imagine my reaction to seeing Adhoc Queries sucking up ~75% of the cumulative CPU Usage and 80-90% of the Logical IO!

    So I started looking into the "Optimize for adhoc workloads." I read the articles by Kimberly Tripp, Technet stuff, and others, and it sounds like it may not be a bad idea to enable.

    The server in question only has 4GB of RAM, and I suspect I could put in a request to get it doubled, but it's like pulling teeth from an angry hyena...

    Running a couple queries agains dm_exec_cached_plans, out of 12975 cached plans, 10148 are adhoc, and 4910 of those are with usecounts of 1...

    Now, I know enabling this won't immediately have an effect on the plan cache, and it will have something of a detrimental effect on the adhoc queries (no cached plan, takes longer to run.) I'd enable it in a test environment first, but the test server won't get hit as hard as the production...

    So anyways, does it sound like it might provide some benefit to enable this option?

    Thanks,

    Jason

  • Hi,

    Without knowing more about the server it is hard to make a call. How many and now big are the databases on it? What type of work load does it churn throughout one business cycle?

    Andrew

  • jasona.work (6/28/2013)


    I recently ran the "Server Dashboard" report on a new server here. Imagine my reaction to seeing Adhoc Queries sucking up ~75% of the cumulative CPU Usage and 80-90% of the Logical IO!

    So I started looking into the "Optimize for adhoc workloads." I read the articles by Kimberly Tripp, Technet stuff, and others, and it sounds like it may not be a bad idea to enable.

    The server in question only has 4GB of RAM, and I suspect I could put in a request to get it doubled, but it's like pulling teeth from an angry hyena...

    Running a couple queries agains dm_exec_cached_plans, out of 12975 cached plans, 10148 are adhoc, and 4910 of those are with usecounts of 1...

    Now, I know enabling this won't immediately have an effect on the plan cache, and it will have something of a detrimental effect on the adhoc queries (no cached plan, takes longer to run.) I'd enable it in a test environment first, but the test server won't get hit as hard as the production...

    So anyways, does it sound like it might provide some benefit to enable this option?

    Thanks,

    Jason

    Using a modified version of Kimberly's script helped me tame one SQL 2005 instance (no optimize for adhoc available) I had running on a 32-bit system with only 2.5 GBs of RAM set aside for the buffer pool: Plan cache, adhoc workloads and clearing the single-use plan cache bloat[/url]. If I had had the option I most definitely would have enabled optimize for adhoc.

    Personally I do not see many downsides to enabling the setting, even on a system where stored procedures are predominantly used. The overhead of generating the stub-plan the first time around and deferring the full plan being cached until the second use has not proven to be detrimental to any of my systems. I enable the setting by default on all new instances.

    If you are concerned or just simply want to see how it goes in a non-production environment you could run a Trace in production using the Replay template (server-side to a file though, not to a Profiler rowset) for as long as your system can stand it performance-wise. Then use that Trace file as a workload to run against a non-production database (after restarting the instance to slcear all caches) with the setting off, take your timings, and then run the workload again after enabling the setting and restarting the instance (to clear all caches again) to see if there is any negligible difference in performance or plan cache usage.

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply