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

      <tfoot id='NxuDy'></tfoot>

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

      有什么理由担心表中的列顺序吗?

      Is there any reason to worry about the column order in a table?(有什么理由担心表中的列顺序吗?)
    2. <i id='hxztk'><tr id='hxztk'><dt id='hxztk'><q id='hxztk'><span id='hxztk'><b id='hxztk'><form id='hxztk'><ins id='hxztk'></ins><ul id='hxztk'></ul><sub id='hxztk'></sub></form><legend id='hxztk'></legend><bdo id='hxztk'><pre id='hxztk'><center id='hxztk'></center></pre></bdo></b><th id='hxztk'></th></span></q></dt></tr></i><div id='hxztk'><tfoot id='hxztk'></tfoot><dl id='hxztk'><fieldset id='hxztk'></fieldset></dl></div>

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

              • <bdo id='hxztk'></bdo><ul id='hxztk'></ul>

                  <tbody id='hxztk'></tbody>
                <tfoot id='hxztk'></tfoot>

                <legend id='hxztk'><style id='hxztk'><dir id='hxztk'><q id='hxztk'></q></dir></style></legend>
                本文介绍了有什么理由担心表中的列顺序吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我知道您可以使用 FIRST 和 AFTER 更改 MySQL 中的列顺序,但是您为什么要费心呢?由于良好的查询在插入数据时会显式命名列,是否真的有任何理由关心您的列在表中的顺序?

                I know you can ALTER the column order in MySQL with FIRST and AFTER, but why would you want to bother? Since good queries explicitly name columns when inserting data, is there really any reason to care what order your columns are in in the table?

                推荐答案

                列顺序对我调整过的一些数据库(包括 Sql Server、Oracle 和 MySQL)有很大的性能影响.这篇文章有良好的经验法则:

                Column order had a big performance impact on some of the databases I've tuned, spanning Sql Server, Oracle, and MySQL. This post has good rules of thumb:

                • 主键列优先
                • 接下来是外键列.
                • 接下来经常搜索的列
                • 以后经常更新列
                • 可空列最后.
                • 在更频繁使用的可空列之后使用最少的可空列

                性能差异的一个例子是索引查找.数据库引擎根据索引中的一些条件找到一行,并取回一个行地址.现在假设你正在寻找 SomeValue,它就在这个表中:

                An example for difference in performance is an Index lookup. The database engine finds a row based on some conditions in the index, and gets back a row address. Now say you are looking for SomeValue, and it's in this table:

                 SomeId int,
                 SomeString varchar(100),
                 SomeValue int
                

                引擎必须猜测 SomeValue 的起始位置,因为 SomeString 的长度未知.但是,如果您将顺序更改为:

                The engine has to guess where SomeValue starts, because SomeString has an unknown length. However, if you change the order to:

                 SomeId int,
                 SomeValue int,
                 SomeString varchar(100)
                

                现在引擎知道可以在行开始后 4 个字节找到 SomeValue.因此,列顺序会对性能产生相当大的影响.

                Now the engine knows that SomeValue can be found 4 bytes after the start of the row. So column order can have a considerable performance impact.

                Sql Server 2005 在行的开头存储固定长度的字段.每行都有一个对 varchar 开头的引用.这完全否定了我上面列出的效果.所以对于最近的数据库,列顺序不再有任何影响.

                Sql Server 2005 stores fixed-length fields at the start of the row. And each row has a reference to the start of a varchar. This completely negates the effect I've listed above. So for recent databases, column order no longer has any impact.

                这篇关于有什么理由担心表中的列顺序吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                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 查询中包含缺失的月份)
                  <bdo id='8I4n7'></bdo><ul id='8I4n7'></ul>
                  <i id='8I4n7'><tr id='8I4n7'><dt id='8I4n7'><q id='8I4n7'><span id='8I4n7'><b id='8I4n7'><form id='8I4n7'><ins id='8I4n7'></ins><ul id='8I4n7'></ul><sub id='8I4n7'></sub></form><legend id='8I4n7'></legend><bdo id='8I4n7'><pre id='8I4n7'><center id='8I4n7'></center></pre></bdo></b><th id='8I4n7'></th></span></q></dt></tr></i><div id='8I4n7'><tfoot id='8I4n7'></tfoot><dl id='8I4n7'><fieldset id='8I4n7'></fieldset></dl></div>

                  <tfoot id='8I4n7'></tfoot>

                        • <legend id='8I4n7'><style id='8I4n7'><dir id='8I4n7'><q id='8I4n7'></q></dir></style></legend>
                            <tbody id='8I4n7'></tbody>

                          <small id='8I4n7'></small><noframes id='8I4n7'>