<tfoot id='d2VVY'></tfoot>

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

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

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

        哪个最快?SELECT SQL_CALC_FOUND_ROWS FROM `table`,或 SE

        时间:2023-08-18

      1. <tfoot id='vqDl9'></tfoot>
        <legend id='vqDl9'><style id='vqDl9'><dir id='vqDl9'><q id='vqDl9'></q></dir></style></legend>

          <i id='vqDl9'><tr id='vqDl9'><dt id='vqDl9'><q id='vqDl9'><span id='vqDl9'><b id='vqDl9'><form id='vqDl9'><ins id='vqDl9'></ins><ul id='vqDl9'></ul><sub id='vqDl9'></sub></form><legend id='vqDl9'></legend><bdo id='vqDl9'><pre id='vqDl9'><center id='vqDl9'></center></pre></bdo></b><th id='vqDl9'></th></span></q></dt></tr></i><div id='vqDl9'><tfoot id='vqDl9'></tfoot><dl id='vqDl9'><fieldset id='vqDl9'></fieldset></dl></div>
            <bdo id='vqDl9'></bdo><ul id='vqDl9'></ul>
              <tbody id='vqDl9'></tbody>
            • <small id='vqDl9'></small><noframes id='vqDl9'>

                  本文介绍了哪个最快?SELECT SQL_CALC_FOUND_ROWS FROM `table`,或 SELECT COUNT(*)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  当你限制一个SQL查询返回的行数时,通常用于分页,有两种方法可以确定总记录数:

                  When you limit the number of rows to be returned by a SQL query, usually used in paging, there are two methods to determine the total number of records:

                  在原SELECT中包含SQL_CALC_FOUND_ROWS选项,然后通过运行SELECT FOUND_ROWS()得到总行数:>

                  Include the SQL_CALC_FOUND_ROWS option in the original SELECT, and then get the total number of rows by running SELECT FOUND_ROWS():

                  SELECT SQL_CALC_FOUND_ROWS * FROM table WHERE id > 100 LIMIT 10;
                  SELECT FOUND_ROWS();  
                  

                  方法二

                  正常运行查询,然后通过运行SELECT COUNT(*)

                  SELECT * FROM table WHERE id > 100 LIMIT 10;
                  SELECT COUNT(*) FROM table WHERE id > 100;  
                  

                  哪种方法最好/最快?

                  推荐答案

                  视情况而定.请参阅有关此主题的 MySQL 性能博客文章:要SQL_CALC_FOUND_ROWS 还是不SQL_CALC_FOUND_ROWS?

                  It depends. See the MySQL Performance Blog post on this subject: To SQL_CALC_FOUND_ROWS or not to SQL_CALC_FOUND_ROWS?

                  只是一个简短的总结:彼得说这取决于您的索引和其他因素.该帖子的许多评论似乎都说 SQL_CALC_FOUND_ROWS 几乎总是比运行两个查询慢 - 有时最多慢 10 倍.

                  Just a quick summary: Peter says that it depends on your indexes and other factors. Many of the comments to the post seem to say that SQL_CALC_FOUND_ROWS is almost always slower - sometimes up to 10x slower - than running two queries.

                  这篇关于哪个最快?SELECT SQL_CALC_FOUND_ROWS FROM `table`,或 SELECT COUNT(*)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:字符集和排序规则到底是什么意思? 下一篇:如何判断 MySQL 表的上次更新时间?

                  相关文章

                  最新文章

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

                  <i id='WiKiN'><tr id='WiKiN'><dt id='WiKiN'><q id='WiKiN'><span id='WiKiN'><b id='WiKiN'><form id='WiKiN'><ins id='WiKiN'></ins><ul id='WiKiN'></ul><sub id='WiKiN'></sub></form><legend id='WiKiN'></legend><bdo id='WiKiN'><pre id='WiKiN'><center id='WiKiN'></center></pre></bdo></b><th id='WiKiN'></th></span></q></dt></tr></i><div id='WiKiN'><tfoot id='WiKiN'></tfoot><dl id='WiKiN'><fieldset id='WiKiN'></fieldset></dl></div>

                • <legend id='WiKiN'><style id='WiKiN'><dir id='WiKiN'><q id='WiKiN'></q></dir></style></legend>

                      <tfoot id='WiKiN'></tfoot>
                      • <bdo id='WiKiN'></bdo><ul id='WiKiN'></ul>