Sqlserver cache plan-Clear the cache plan that is only used once, And Cache

Source: Internet
Author: User

Sqlserver cache plan-Clear the cache plan that is only used once, And Cache

The plan cache is very large and will only be cleared once using the cache plan, instead of the entire cache. declare @ sid varbinary (64) declare cur01 cursor forselect plan_handle from (SELECT plan_handle FROM sys. dm_exec_cached_plans AS cp cross apply sys. dm_exec_ SQL _text (cp. plan_handle) stWHERE cp. cacheobjtype = n' Compiled Plan 'AND cp. objtype IN (N 'adhoc ', N 'prepared') AND cp. usecounts = 1 and text like 'select % ') copen cur01fetch next from cur01 into @ sidwhile @ fetch_status = 0 beginDBCC FREEPROCCACHE (@ sid) fetch next from cur01 into @ sidendclose export cur01go


 

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.