• <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中如何选择聚集索引?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  Building a comma separated list?(建立一个逗号分隔的列表?)
                  Errors in SQL Server while importing CSV file despite varchar(MAX) being used for each column(尽管每列都使用了 varchar(MAX),但在导入 CSV 文件时 SQL Server 中出现错误)
                  How can I import an Excel file into SQL Server?(如何将 Excel 文件导入 SQL Server?)
                  Export table to file with column headers (column names) using the bcp utility and SQL Server 2008(使用 bcp 实用程序和 SQL Server 2008 将表导出到带有列标题(列名称)的文件)
                  Concat field value to string in SQL Server(将字段值连接到 SQL Server 中的字符串)
                  SQL Server Bulk insert of CSV file with inconsistent quotes(SQL Server 批量插入带有不一致引号的 CSV 文件)

                    <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>