• SQL SERVER 索引维护


    -- 全数据库索引重建

    DECLARE @name varchar(100)
    DECLARE authors_cursor CURSOR FOR Select [name] from sysobjects where xtype='u' order by id
    OPEN authors_cursor
    FETCH NEXT FROM authors_cursor INTO @name
    WHILE @@FETCH_STATUS = 0
    BEGIN
     DBCC DBREINDEX (@name, '', 90)
    FETCH NEXT FROM authors_cursor INTO @name
    END
    deallocate authors_cursor

    -- 单表数据库维护

    -- 单表重建索引

    dbcc dbreindex('表名',索引名称,100)

    -- 查看表索引密集度

    declare @table_id int
    set @table_id=object_id('表名称')
    dbcc showcontig(@table_id)

    --参数说明,第三个参数表示填充因子

    低更改的表(读写比率为100:1):100%的填充因子
    高更改的表(写超过读):50-70%的填充因子
    读写各一半的:80-90%的填充因子

    -- 数据库检查碎片

    DBCC ShowContig
    DBCC ShowContig(表名)

  • 相关阅读:
    Interrupt、Interrupted、IsInterrupted
    ReentrantLock
    tcp粘包、拆包
    jstat 分析应用垃圾回收状况
    CopyOnWriteArrayList
    storm基础概念
    余弦距离
    websocket
    awk
    sed
  • 原文地址:https://www.cnblogs.com/chengeng/p/6422688.html
Copyright © 2020-2023  润新知