• <tfoot id='9aUGV'></tfoot>

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

          <bdo id='9aUGV'></bdo><ul id='9aUGV'></ul>
      1. <small id='9aUGV'></small><noframes id='9aUGV'>

      2. SQL Server中如何选择聚集索引?

        How to choose the clustered index in SQL Server?(SQL Server中如何选择聚集索引?)
            <bdo id='LGrMi'></bdo><ul id='LGrMi'></ul>

              <tbody id='LGrMi'></tbody>

            <tfoot id='LGrMi'></tfoot>

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

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

                2. <legend id='LGrMi'><style id='LGrMi'><dir id='LGrMi'><q id='LGrMi'></q></dir></style></legend>
                  本文介绍了SQL Server中如何选择聚集索引?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  通常在 SQL Server Management Studio 中通过设置主键创建聚集索引,但是我最近关于 PK <-> 聚集索引的问题 (主键对Microsoft SQL Server 2008 的意义) 已经表明没有必要将PK 和聚集索引设置为相等.

                  Usually the clustered index is created in SQL Server Management Studio by setting the primary key, however my recent question about PK <-> clustered index (Meaning of Primary Key to Microsoft SQL Server 2008) has shown that it is not necessary to set PK and clustered index to be equal.

                  那我们应该如何选择聚集索引呢?举个例子:

                  So how should we choose clustered indexes then? Let's have the following example:

                  create table Customers (ID int, ...)
                  create table Orders (ID int, CustomerID int)
                  

                  我们通常会在两个 ID 列上创建 PK/CI,但我考虑为 CustomerID 中的订单创建它.这是最好的选择吗?

                  We would usually create the PK/CI on both ID columns but I thought about creating it for Orders in CustomerID. Is that the best choice?

                  推荐答案

                  根据索引女王 - Kimberly Tripp - 她在聚集索引中寻找的主要是:

                  According to The Queen Of Indexing - Kimberly Tripp - what she looks for in a clustered index is primarily:

                  • 独一无二
                  • 静态

                  如果你也能保证:

                  • 不断增加的模式

                  那么您就非常接近拥有理想的聚类密钥了!

                  then you're pretty close to having your ideal clustering key!

                  查看她的整个此处的博客文章,还有另一篇关于聚类关键影响对表操作的非常有趣的文章:聚集索引辩论继续.

                  Check out her entire blog post here, and another really interesting one about clustering key impacts on table operations here: The Clustered Index Debate Continues.

                  任何像 INT(特别是 INT IDENTITY)或可能是 INT 和 DATETIME 的东西都是理想的候选者.由于其他原因,GUID 根本不是很好的候选对象 - 因此您可能有一个 GUID 作为您的 PK,但不要将您的表聚集在其上 - 它会被分割得无法识别并且性能会受到影响.

                  Anything like an INT (esp. an INT IDENTITY) or possibly an INT and a DATETIME are ideal candiates. For other reasons, GUID's aren't good candidates at all - so you might have a GUID as your PK, but don't cluster your table on it - it'll be fragmented beyond recognition and performance will suffer.

                  这篇关于SQL Server中如何选择聚集索引?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  ibtmp1是非压缩的innodb临时表的独立表空间,通过innodb_temp_data_file_path参数指定文件的路径,文件名和大小,默认配置为ibtmp1:12M:autoextend,也就是说在文件系统磁盘足够的情况下,这个文件大小是可以无限增长的。 为了避免ibtmp1文件无止境的暴涨导致
                  SQL query to group by day(按天分组的 SQL 查询)
                  What does SQL clause quot;GROUP BY 1quot; mean?(SQL 子句“GROUP BY 1是什么意思?意思是?)
                  MySQL groupwise MAX() returns unexpected results(MySQL groupwise MAX() 返回意外结果)
                  MySQL SELECT most frequent by group(MySQL SELECT 按组最频繁)
                  Include missing months in Group By query(在 Group By 查询中包含缺失的月份)

                    <tbody id='FCca7'></tbody>

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

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

                        <bdo id='FCca7'></bdo><ul id='FCca7'></ul>

                          <tfoot id='FCca7'></tfoot>
                            <legend id='FCca7'><style id='FCca7'><dir id='FCca7'><q id='FCca7'></q></dir></style></legend>