LIMIT子句对MySQL性能的影响? [英] The effect of a LIMIT clause on performance in MySQL?

查看:234
本文介绍了LIMIT子句对MySQL性能的影响?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怀疑我已经知道答案了,但是...

I suspect I know the answer to this already, but...

给出以下3条MySQL语句:

Given the following 3 MySQL statements:

SELECT SQL_CALC_FOUND_ROWS title FROM STUFF LIMIT 1000000, 1;
SELECT SQL_CALC_FOUND_ROWS title FROM STUFF LIMIT 1;
SELECT title FROM STUFF;

这三个之间的性能是否有显着差异?

Is there a significant difference in performance between the three?

推荐答案

SQL_CALC_FOUND_ROWS需要遍历所有行以计算答案,因此在1和2之间没有时间差(除了第一个查询可能不会如果表中的行数少于1000000,则返回任何内容)

SQL_CALC_FOUND_ROWS needs to iterate over all lines to compute the answer, so there is no time defference between the 1 and 2 (except for the first query might not return anything if you have less than 1000000 rows in the table)

第三个查询将输出整个表,而不仅仅是计数它的行.

The third query will output the whole table, not just count its rows.

这篇关于LIMIT子句对MySQL性能的影响?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆