使用 order by 时,存储在 INT(10) 列中的数字的长度是否会影响性能。
我目前在 INT(10) 列中有一些 7 位长数字,这些数字是使用 order by 排序的。
如果大量订购会降低性能,我可以尝试其他方法。他们会放慢速度吗?
最佳答案
不,它不会影响性能,因为 INT
type 的长度固定为 4B 。
因此,无论您有 1 位数字还是 10 位数字,性能都应该相同。
这也是关于 INT(N)
的一般错误信息N代表要显示的位数,换句话说INT(1)
与 INT(10)
大小相同
UPDATE 如果你想加速ORDER BY
部分你可以添加 INDEX
在那个专栏上
In some cases, MySQL can use an index to satisfy an ORDER BY clause without doing any extra sorting.
The index can also be used even if the ORDER BY does not match the index exactly, as long as all of the unused portions of the index and all the extra ORDER BY columns are constants in the WHERE clause
关于mysql - 使用 order by 时,数字的长度会影响 mysql 中的性能吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16612726/