SQL Server clears the cache, logs the query time

Source: Internet
Author: User

--1. Writes all dirty pages of the current database to disk. A dirty page is a page of data that has been entered into a buffer cache and has been modified but not yet written to disk. --   CHECKPOINT can create a checkpoint that guarantees that all dirty pages have been written to disk, saving time in a later recovery process. Checkpoint--2. To remove the purge buffer from the buffer pool, first use CHECKPOINT to generate a cold cache. This forces all dirty pages of the current database to be written to disk, and then clears the buffer. --   Once this is done, you can issue the DBCC dropcleanbuffers command to remove all buffers from the buffer pool. DBCC dropcleanbuffers--3. Releasing the process cache causes the system to recompile some statements (for example, ad hoc SQL statements) without reusing the statements in the cache. DBCC freeproccache--4. Frees all unused cache entries from all caches. SQL Server 2005 Database Engine cleans unused cache entries in the background beforehand so that memory is available for the current entry. --  However, you can use this command to manually remove unused entries from all caches. DBCC Freesystemcache (' all ')--5. To proceed with your query, SQL Server will automatically read the most likely data page into the cache at all times.

  

CHECKPOINT;DBCC dropcleanbuffers;dbcc freeproccache;dbcc freesystemcache (' all '); Set STATISTICS time on;--Query condition set STATISTICS time OFF;

  

SQL Server clears the cache, logs the query time

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.