<bdo id='hEHEb'></bdo><ul id='hEHEb'></ul>

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

    1. <tfoot id='hEHEb'></tfoot>
      <legend id='hEHEb'><style id='hEHEb'><dir id='hEHEb'><q id='hEHEb'></q></dir></style></legend>
      <i id='hEHEb'><tr id='hEHEb'><dt id='hEHEb'><q id='hEHEb'><span id='hEHEb'><b id='hEHEb'><form id='hEHEb'><ins id='hEHEb'></ins><ul id='hEHEb'></ul><sub id='hEHEb'></sub></form><legend id='hEHEb'></legend><bdo id='hEHEb'><pre id='hEHEb'><center id='hEHEb'></center></pre></bdo></b><th id='hEHEb'></th></span></q></dt></tr></i><div id='hEHEb'><tfoot id='hEHEb'></tfoot><dl id='hEHEb'><fieldset id='hEHEb'></fieldset></dl></div>
    2. MYSQL count(*) 和 count(1) 哪个更好?

      What is better in MYSQL count(*) or count(1)?(MYSQL count(*) 和 count(1) 哪个更好?)

      <legend id='R3p1H'><style id='R3p1H'><dir id='R3p1H'><q id='R3p1H'></q></dir></style></legend>
      • <tfoot id='R3p1H'></tfoot>
            <tbody id='R3p1H'></tbody>

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

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

              • <small id='R3p1H'></small><noframes id='R3p1H'>

                本文介绍了MYSQL count(*) 和 count(1) 哪个更好?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                相关(SQL Server): Count(*) vs Count(1)

                你能告诉我什么是更好的性能(MySQL)吗?计数(*)还是计数(1)?

                Could you please tell me what is better in performance (MySQL)? Count(*) or count(1)?

                推荐答案

                这是 MySQL 的答案.

                This is a MySQL answer.

                它们的执行完全相同 - 除非您使用的是 MyISAM,否则存在 COUNT(*) 的特殊情况.无论如何,我总是使用 COUNT(*).

                They perform exactly the same - unless you are using MyISAM, then a special case for COUNT(*) exists. I always use COUNT(*) anyway.

                https://dev.mysql.com/doc/refman/5.6/en/aggregate-functions.html#function_count

                对于 MyISAM 表,COUNT(*) 被优化为快速返回,如果SELECT 从一张表中检索,不检索其他列,并且没有 WHERE 子句.例如:

                For MyISAM tables, COUNT(*) is optimized to return very quickly if the SELECT retrieves from one table, no other columns are retrieved, and there is no WHERE clause. For example:

                mysql> SELECT COUNT(*) FROM student;
                

                此优化仅适用于MyISAM表,因为为此存储引擎存储了精确的行数并且可以非常快速地访问.COUNT(1) 只受相同如果第一列定义为NOT NULL,则优化.

                This optimization only applies to MyISAM tables, because an exact row count is stored for this storage engine and can be accessed very quickly. COUNT(1) is only subject to the same optimization if the first column is defined as NOT NULL.

                <小时>###编辑你们中的一些人可能错过了幽默的黑暗尝试.我更愿意将此作为一个非重复的问题,以便 MySQL 对 SQL Server 做一些不同的事情.所以我投票重新提出这个问题(答案显然是错误的).

                上述MyISAM优化同样适用于


                ###EDIT Some of you may have missed the dark attempt at humour. I prefer to keep this as a non-duplicate question for any such day when MySQL will do something different to SQL Server. So I threw a vote to reopen the question (with a clearly wrong answer).

                The above MyISAM optimization applies equally to

                COUNT(*)
                COUNT(1)
                COUNT(pk-column)
                COUNT(any-non-nullable-column)
                

                所以真正的答案是它们总是相同.

                So the real answer is that they are always the same.

                这篇关于MYSQL count(*) 和 count(1) 哪个更好?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                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='W5diP'></bdo><ul id='W5diP'></ul>

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

                    2. <legend id='W5diP'><style id='W5diP'><dir id='W5diP'><q id='W5diP'></q></dir></style></legend>

                      • <small id='W5diP'></small><noframes id='W5diP'>

                      • <tfoot id='W5diP'></tfoot>
                          <tbody id='W5diP'></tbody>