- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我确信执行时间与 MySQL 查询中的行数成正比。我的问题是,比例是多少?随着数据库变大,查询的执行时间会显着增加还是只增加一点点?
有关该主题的任何信息将不胜感激
最佳答案
不,不是真的。
select * from table
将花费更长的时间(如果您有很多行,对于只有四行的表,它所花费的时间不会是有两行的表的两倍,这将是以“固定成本”为主)
无论表大小如何,select * from table limit 10
都将花费相同的时间。
select count(*) from table
在 MySQL 上是即时的,无论表大小如何。
select * from table where Primary_key = ?
将以对数方式缩放(因为使用了 B 树索引)。
select count(*) from table where non_indexed_column = ?
将花费相应更长的时间,但 select count(*) from table where indexed_column = ?
则不会.
如果行数加倍,select * from table_a join table_b
将花费四倍的时间。 使用 (column_a = indexed_column_b) select * from table_a join table_b
应线性缩放。
如果行数加倍,select * from table_a order by unindexed_column
将花费两倍以上的时间。 select * from table_a order by indexed_column
可以按比例缩放,但 select * from table_a where some = ?按indexed_column排序
可能不会。
一旦表不再适合内存,所有操作都会花费更多时间。或者,如果您在内存用于其他表时运行查询。这可能是真正的障碍,执行时间会突然飙升。
此外,您还考虑了“查询中的行”(选定的行)和“表中的行”。这两者都有影响。表中已删除行的“存在”也会产生影响。
关于mysql - 执行时间与行数成正比吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12418860/
我有一个 45Gb 的表,大约有 76M 行和 150 列。 当我运行以下简单查询时: SELECT count(*) FROM my_table WHERE `column_of_interest`
如果数组已满并且其大小增加 1 以插入新元素,则插入 N 个元素的时间可以计算为 1+2+ .. N = N^2/2。 (声明长度为 size+1 的新数组并将元素复制到新数组)。 我无法理解,如果不
我是一名优秀的程序员,十分优秀!