1. <tfoot id='7otkZ'></tfoot>

      <small id='7otkZ'></small><noframes id='7otkZ'>

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

        <bdo id='7otkZ'></bdo><ul id='7otkZ'></ul>

      1. <legend id='7otkZ'><style id='7otkZ'><dir id='7otkZ'><q id='7otkZ'></q></dir></style></legend>

        是否可以加速 MySQL 中的 sum()?

        时间:2023-10-26

          <tfoot id='pAgEC'></tfoot>

          1. <legend id='pAgEC'><style id='pAgEC'><dir id='pAgEC'><q id='pAgEC'></q></dir></style></legend>
              <bdo id='pAgEC'></bdo><ul id='pAgEC'></ul>

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

                  <tbody id='pAgEC'></tbody>
                  <i id='pAgEC'><tr id='pAgEC'><dt id='pAgEC'><q id='pAgEC'><span id='pAgEC'><b id='pAgEC'><form id='pAgEC'><ins id='pAgEC'></ins><ul id='pAgEC'></ul><sub id='pAgEC'></sub></form><legend id='pAgEC'></legend><bdo id='pAgEC'><pre id='pAgEC'><center id='pAgEC'></center></pre></bdo></b><th id='pAgEC'></th></span></q></dt></tr></i><div id='pAgEC'><tfoot id='pAgEC'></tfoot><dl id='pAgEC'><fieldset id='pAgEC'></fieldset></dl></div>
                • 本文介绍了是否可以加速 MySQL 中的 sum()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在对 MySQL 数据库执行select sum(foo) from bar"查询,该查询汇总了 7.3 毫米的记录,每次运行大约需要 22 秒.在 MySQL 中是否有加速求和的技巧?

                  I'm doing a "select sum(foo) from bar" query on a MySQL database that's summing up 7.3mm records and taking about 22 seconds per run. Is there a trick to speeding up sums in MySQL?

                  推荐答案

                  不,你不能加速函数本身.这里的问题实际上是您要选择 730 万条记录.MySQL 必须扫描整个表,730 万是一个相当大的数字.实际上,它完成得如此之快给我留下了深刻的印象.

                  No, you can't speed up the function itself. The problem here is really that you're selecting 7.3 million records. MySQL has to scan the entire table, and 7.3 million is a pretty big number. I'm impressed that it finishes that fast, actually.

                  您可以采用的一种策略是将您的数据分解为更小的子集(可能按日期?月?)并为不会更改的旧数据维护一个总和.您可以定期更新总和,可以通过将总和以及此后添加的任何新数据(行数少得多)相加来计算总体值.

                  A strategy you could employ would be to break your data into smaller subsets (perhaps by date? Month?) and maintain a total sum for old data that's not going to change. You could periodically update the sum, and the overall value could be calculated by adding the sum, and any new data that's been added since then, which will be a much smaller number of rows.

                  这篇关于是否可以加速 MySQL 中的 sum()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:SQL Server 中的 PAGEIOLATCH_SH 等待类型是什么? 下一篇:我如何寻求帮助优化 &amp;修复 MySQL 中的查询?

                  相关文章

                • <legend id='2aNtz'><style id='2aNtz'><dir id='2aNtz'><q id='2aNtz'></q></dir></style></legend>

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