zoukankan      html  css  js  c++  java
  • Sqlserver 2005+:查看索引【index】的【碎片】

    set nocount on
    
    
    print db_name()
    
    declare @tab_name sysname
    set @tab_name='wfpuser_a0113'
    
    --内部碎片
    select '【内部】碎片' as frag_type
        ,ob.name as object_name
        ,ix.index_id,ix.name as index_name
        ,ps.index_level
        ,ps.partition_number
        ,ps.record_count
        ,ps.page_count
        ,ps.fragment_count
        ,str(ps.avg_fragmentation_in_percent,16,2) as [avg_frag(%)]
        ,str(ps.avg_fragment_size_in_pages,16,1) as [avg_frag_pages]
        ,ps.forwarded_record_count
        ,ps.avg_record_size_in_bytes
        ,str(ps.avg_page_space_used_in_percent,16,2) as [avg_page_space_used(%)]
    from sys.dm_db_index_physical_stats(db_id(),object_id(@tab_name),default, default, 'detailed') ps
        inner join sys.indexes ix on ix.object_id = ps.object_id and ix.index_id = ps.index_id
        inner join sys.objects ob on ob.object_id=ix.object_id
    where ob.is_ms_shipped=0
    union all
    --外部碎片
    select '外部碎片' as frag_type
        ,ob.name as object_name
        ,ix.index_id,ix.name as index_name
        ,ps.index_level
        ,ps.partition_number
        ,ps.record_count
        ,ps.page_count
        ,ps.fragment_count
        ,str(ps.avg_fragmentation_in_percent,16,2) as [avg_frag(%)]
        ,str(ps.avg_fragment_size_in_pages,16,1) as [avg_frag_pages]
        ,ps.forwarded_record_count
        ,ps.avg_record_size_in_bytes
        ,str(ps.avg_page_space_used_in_percent,16,2) as [avg_page_space_used(%)]
    from sys.dm_db_index_physical_stats(db_id(),object_id(@tab_name),default, default, 'limited') ps
        inner join sys.indexes ix on ix.object_id = ps.object_id and ix.index_id = ps.index_id
        inner join sys.objects ob on ob.object_id=ix.object_id
    where ob.is_ms_shipped=0
    order by object_name,index_id,frag_type
  • 相关阅读:
    LevelDB的源码阅读(二) Open操作
    LevelDB的源码阅读(一)
    Linux上leveldb的安装和使用
    Linux下安装jdk8的详细步骤
    Linux下用ls和du命令查看文件以及文件夹大小
    pytorch实现VAE
    Caffe实现VAE
    pytorch实现DCGAN、pix2pix、DiscoGAN、CycleGAN、BEGAN以及VAE
    PyTorch教程之Training a classifier
    PyTorch教程之Neural Networks
  • 原文地址:https://www.cnblogs.com/jinzhenshui/p/2779425.html
Copyright © 2011-2022 走看看