SQL Server optimizes ad hoc caching

Source: Internet
Author: User

To view the cache plan SQL that SQL Server has used:

SELECTObjType as 'Cached Object Type',COUNT(*) as 'Number of plans',SUM(CAST(size_in_bytes as BIGINT))/1024x768/1024x768  as 'Plan Cache Size (MB)',AVG(usecounts) as 'AVG Use Count' fromSys.dm_exec_cached_plansGROUP  byObjType

The result of the execution is:

Most of the cache plan is the Ad hoc cache Plan (ADHOC) occupancy, 1653Mb, average usage is only 72, lower, and then we look at these occupy the cache only once performed the ad-hoc cache plan:

SELECT     COUNT(*) as 'Number of plans',    SUM(CAST(size_in_bytes as BIGINT))/1024x768/1024x768  as 'Plan Cache Size (MB)' fromSys.dm_exec_cached_plansWHEREUsecounts= 1  andObjType= '

The result of the execution is:

There are 1461 ad-hoc cache plans that have been executed only once, taking up 338Mb in the cache, which is completely wasted on programs that cannot be reused, and can be stripped of cache space by removing these unused cache plans.

Conclusion:

The option to optimize for an ad hoc cache workload ensures that this does not occur and it is recommended that all SQL Server installations be turned on by default.

Option settings:

Open SQL Server Properties--advanced--optimize for ad-hoc workloads->true can

SQL Server optimizes ad hoc caching

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.