<legend id='8WSGX'><style id='8WSGX'><dir id='8WSGX'><q id='8WSGX'></q></dir></style></legend>

<i id='8WSGX'><tr id='8WSGX'><dt id='8WSGX'><q id='8WSGX'><span id='8WSGX'><b id='8WSGX'><form id='8WSGX'><ins id='8WSGX'></ins><ul id='8WSGX'></ul><sub id='8WSGX'></sub></form><legend id='8WSGX'></legend><bdo id='8WSGX'><pre id='8WSGX'><center id='8WSGX'></center></pre></bdo></b><th id='8WSGX'></th></span></q></dt></tr></i><div id='8WSGX'><tfoot id='8WSGX'></tfoot><dl id='8WSGX'><fieldset id='8WSGX'></fieldset></dl></div>

    <tfoot id='8WSGX'></tfoot>
    1. <small id='8WSGX'></small><noframes id='8WSGX'>

        <bdo id='8WSGX'></bdo><ul id='8WSGX'></ul>

      应该多久在我们的 SQL Server 数据库中重建索引?

      How often should the indexes be rebuilt in our SQL Server database?(应该多久在我们的 SQL Server 数据库中重建索引?)
        1. <small id='3lpGM'></small><noframes id='3lpGM'>

        2. <tfoot id='3lpGM'></tfoot>

                <tbody id='3lpGM'></tbody>
              <i id='3lpGM'><tr id='3lpGM'><dt id='3lpGM'><q id='3lpGM'><span id='3lpGM'><b id='3lpGM'><form id='3lpGM'><ins id='3lpGM'></ins><ul id='3lpGM'></ul><sub id='3lpGM'></sub></form><legend id='3lpGM'></legend><bdo id='3lpGM'><pre id='3lpGM'><center id='3lpGM'></center></pre></bdo></b><th id='3lpGM'></th></span></q></dt></tr></i><div id='3lpGM'><tfoot id='3lpGM'></tfoot><dl id='3lpGM'><fieldset id='3lpGM'></fieldset></dl></div>
                <bdo id='3lpGM'></bdo><ul id='3lpGM'></ul>

                <legend id='3lpGM'><style id='3lpGM'><dir id='3lpGM'><q id='3lpGM'></q></dir></style></legend>
              • 本文介绍了应该多久在我们的 SQL Server 数据库中重建索引?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                目前,我们的数据库大小为 10 GB,并且每月增长约 3 GB.我经常听说应该不时重建索引,以提高查询执行时间.那么在给定的场景中,我应该多久重建一次索引?

                Currently our database has size 10 GB and is growing by around 3 GB per month. Often I hear that one should from time to time rebuild the indexes, to improve the query execution time. So how often should I rebuild the indexes in the given scenario?

                推荐答案

                人们普遍认为,一旦索引碎片达到 5 个以上(有时为 10%),就应该重新组织(碎片整理")索引,并且当超过 30% 时应该完全重建它们(至少这是我在很多地方听到的提倡的数字).

                There's a general consensus that you should reorganize ("defragment") your indices as soon as index fragmentation reaches more than 5 (sometimes 10%), and you should rebuild them completely when it goes beyond 30% (at least that's the numbers I've heard advocated in a lot of places).

                Michelle Ufford(又名SQL 傻瓜")有一个 自动索引碎片整理脚本,它使用这些确切的限制来决定何时重组或重建索引.

                Michelle Ufford (a.k.a. "SQL Fool") has an automated index defrag script, which uses those exact limits for deciding when to reorganize or rebuild an index.

                另请参阅 Brad McGehee 关于重建索引的技巧,其中有一些不错的想法和关于如何处理索引重建的提示.

                Also see Brad McGehee's tips on rebuild indexes with some good thoughts and tips on how to deal with index rebuilding.

                我在这里使用这个脚本(不记得我是从什么时候得到的——不管它是谁:非常感谢!真的很有帮助)来显示给定数据库中所有索引的索引碎片:

                I use this script here (can't remember when I got this from - whoever it was: many thanks! Really helpful stuff) to display the index fragmentation on all your indices in a given database:

                SELECT 
                    t.NAME 'Table name',
                    i.NAME 'Index name',
                    ips.index_type_desc,
                    ips.alloc_unit_type_desc,
                    ips.index_depth,
                    ips.index_level,
                    ips.avg_fragmentation_in_percent,
                    ips.fragment_count,
                    ips.avg_fragment_size_in_pages,
                    ips.page_count,
                    ips.avg_page_space_used_in_percent,
                    ips.record_count,
                    ips.ghost_record_count,
                    ips.Version_ghost_record_count,
                    ips.min_record_size_in_bytes,
                    ips.max_record_size_in_bytes,
                    ips.avg_record_size_in_bytes,
                    ips.forwarded_record_count
                FROM 
                    sys.dm_db_index_physical_stats(DB_ID(), NULL, NULL, NULL, 'DETAILED') ips
                INNER JOIN  
                    sys.tables t ON ips.OBJECT_ID = t.Object_ID
                INNER JOIN  
                    sys.indexes i ON ips.index_id = i.index_id AND ips.OBJECT_ID = i.object_id
                WHERE
                    AVG_FRAGMENTATION_IN_PERCENT > 0.0
                ORDER BY
                    AVG_FRAGMENTATION_IN_PERCENT, fragment_count
                    
                

                这篇关于应该多久在我们的 SQL Server 数据库中重建索引?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Maximum stored procedure, function, trigger, or view nesting level exceeded (limit 32)(超出最大存储过程、函数、触发器或视图嵌套级别(限制 32))
                How to debug stored procedure in VS 2015?(如何在 VS 2015 中调试存储过程?)
                How to find a text inside SQL Server procedures / triggers?(如何在 SQL Server 程序/触发器中查找文本?)
                SQL Server stored procedure return code oddity(SQL Server 存储过程返回码奇怪)
                Conditional SQL ORDER BY ASC/DESC for alpha columns(alpha 列的条件 SQL ORDER BY ASC/DESC)
                Export stored procedure result set to Excel in SSMS(在SSMS中将存储过程结果集导出到Excel)

                  <small id='pow11'></small><noframes id='pow11'>

                • <i id='pow11'><tr id='pow11'><dt id='pow11'><q id='pow11'><span id='pow11'><b id='pow11'><form id='pow11'><ins id='pow11'></ins><ul id='pow11'></ul><sub id='pow11'></sub></form><legend id='pow11'></legend><bdo id='pow11'><pre id='pow11'><center id='pow11'></center></pre></bdo></b><th id='pow11'></th></span></q></dt></tr></i><div id='pow11'><tfoot id='pow11'></tfoot><dl id='pow11'><fieldset id='pow11'></fieldset></dl></div>

                    <bdo id='pow11'></bdo><ul id='pow11'></ul>
                    • <tfoot id='pow11'></tfoot>

                            <tbody id='pow11'></tbody>
                        1. <legend id='pow11'><style id='pow11'><dir id='pow11'><q id='pow11'></q></dir></style></legend>