zoukankan      html  css  js  c++  java
  • 查看SQLServer各种缓存的情况

    查看页面缓存:

    SELECT * FROM sys.dm_os_buffer_descriptors

    清除页面缓存:

    CHECKPOINT
    DBCC
    DROPCLEANBUFFERS

    查看执行计划缓存:

    SELECT * FROM sys.dm_exec_cached_plans

    清除执行计划缓存:

    DBCC FREEPROCCACHE 或者 DBCC FREESYSTEMCACHE('ALL')

    综合应用:

    SELECT * FROM (SELECT database_id,obj.name, i.name AS IndexName,page_type,count(*) AS cached_pages_count
    FROM sys.dm_os_buffer_descriptors AS bd 
        INNER JOIN 
        (
            SELECT p.object_id, object_name(p.object_id) AS name 
                ,index_id ,allocation_unit_id
            FROM sys.allocation_units AS au
                INNER JOIN sys.partitions AS p 
                ON au.container_id = p.hobt_id 
                INNER JOIN sys.objects as o
                ON p.object_id = o.object_id
                WHERE (au.type = 1 OR au.type = 3) and o.type in ('U','V')
            UNION ALL
            SELECT p.object_id, object_name(p.object_id) AS name   
                ,index_id, allocation_unit_id
            FROM sys.allocation_units AS au
                INNER JOIN sys.partitions AS p
                ON au.container_id = p.partition_id 
                INNER JOIN sys.objects AS o
                ON p.object_id = o.object_id
                WHERE au.type= 2 and o.type in ('U','V')
        ) AS obj ON bd.allocation_unit_id = obj.allocation_unit_id
        LEFT JOIN sysindexes i ON obj.object_id = i.id AND obj.index_id = i.indid
    GROUP BY database_id,page_type,obj.name, index_id, i.name) AS c 
    --WHERE database_id = db_id()
    ORDER BY database_id,name,IndexName,page_type,cached_pages_count DESC;
  • 相关阅读:
    Docker Mysql 只从复制
    Mysql 常用sql记录
    ssh 内网穿透
    MyBatis相关记录
    mybatis(plus) 继承子模块的 Mapper文件
    Navicat 连接 Mysql 错误 2059
    angular service 进行组件通信
    angular 中的 ? 和 !
    angular @Input() 和 @Output()
    Centos7 安装 Docker CE
  • 原文地址:https://www.cnblogs.com/zanxiaofeng/p/3642731.html
Copyright © 2011-2022 走看看