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

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

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

      1. <tfoot id='tOurC'></tfoot>
        <legend id='tOurC'><style id='tOurC'><dir id='tOurC'><q id='tOurC'></q></dir></style></legend>
      2. MySQL 视图性能

        时间:2023-05-31

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

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

                <tbody id='7ixvU'></tbody>
            1. <tfoot id='7ixvU'></tfoot>
                <bdo id='7ixvU'></bdo><ul id='7ixvU'></ul>
                1. <legend id='7ixvU'><style id='7ixvU'><dir id='7ixvU'><q id='7ixvU'></q></dir></style></legend>

                  本文介绍了MySQL 视图性能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一张可容纳大约 100,000 个用户的表.

                  I have a table for about 100,000 users in it.

                  第一种情况:

                  explain select state, count(*) as cnt from users where state = 'ca'
                  

                  当我为上述查询做一个解释计划时,我得到的成本为 5200

                  When I do an explain plan for the above query I get the cost as 5200

                  第二种情况:

                  Create or replace view vw_users as select state, count(*) as cnt from users
                  
                  Explain select cnt from vw_users where state = 'ca'
                  

                  当我对第二个查询执行解释计划时,我得到的成本为 100,000.

                  When I do an explain plan on the second query I get the cost as 100,000.

                  视图中的 where 子句是如何工作的?视图检索所有行后是否应用 where 子句?我该如何解决这个问题?

                  How does the where clause in the view work? Is the where clause applied after the view retrieves all the rows? How do I fix this issue?

                  推荐答案

                  关于 查看算法 已使用.

                  merge 算法适用于大多数表索引等 - temptable 算法没有 - 在许多情况下,您的索引将完全没有使用.

                  The merge algorithm works well most table indexes and whatnot - the temptable algorithm doesn't - in many cases your indexes will just be flat-out not used at all.

                  还有很多不支持的废话

                  如果视图无法使用 MERGE包含以下任何一项构造:

                  MERGE cannot be used if the view contains any of the following constructs:

                  * Aggregate functions (SUM(), MIN(), MAX(), COUNT(), and so forth)
                  * DISTINCT
                  * GROUP BY
                  * HAVING
                  * LIMIT
                  * UNION or UNION ALL
                  * Subquery in the select list
                  * Refers only to literal values (in this case, there is no underlying table)
                  

                  这篇关于MySQL 视图性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何在 MySQL 中将自动增量格式设置为 0001? 下一篇:计算给定2个点,纬度和经度的距离

                  相关文章

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

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

                      <legend id='zmclP'><style id='zmclP'><dir id='zmclP'><q id='zmclP'></q></dir></style></legend><tfoot id='zmclP'></tfoot>