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

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

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

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

      mysql fix 使用 where;

      时间:2023-10-25
      <legend id='XzseA'><style id='XzseA'><dir id='XzseA'><q id='XzseA'></q></dir></style></legend>
        <bdo id='XzseA'></bdo><ul id='XzseA'></ul>
        • <tfoot id='XzseA'></tfoot>

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

                <tbody id='XzseA'></tbody>
            • <i id='XzseA'><tr id='XzseA'><dt id='XzseA'><q id='XzseA'><span id='XzseA'><b id='XzseA'><form id='XzseA'><ins id='XzseA'></ins><ul id='XzseA'></ul><sub id='XzseA'></sub></form><legend id='XzseA'></legend><bdo id='XzseA'><pre id='XzseA'><center id='XzseA'></center></pre></bdo></b><th id='XzseA'></th></span></q></dt></tr></i><div id='XzseA'><tfoot id='XzseA'></tfoot><dl id='XzseA'><fieldset id='XzseA'></fieldset></dl></div>
                本文介绍了mysql fix 使用 where;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我的 SQL 查询:

                SELECT *
                FROM updates_cats
                WHERE uid =118697835834
                ORDER BY created_date ASC
                

                当前索引:

                index1(uid, created_date)
                

                解释扩展结果:

                1 SIMPLE updates_cats ref index1 index1 8 const 2 100.00 Using where
                

                如何修复 Extra 字段使用的地方,以便它可以使用索引?

                How can i fix the Extra field where it has Using where so it can use the indexes instead?

                显示创建表:

                CREATE TABLE `updates_cats` (
                 `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
                 `u_cat_id` bigint(20) NOT NULL DEFAULT '0',
                 `uid` bigint(20) NOT NULL,
                 `u_cat_name` text COLLATE utf8_unicode_ci NOT NULL,
                 `total_updates` int(11) unsigned NOT NULL DEFAULT '0',
                 `created_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
                 PRIMARY KEY (`id`),
                 KEY `index1` (`uid`,`created_date`)
                ) ENGINE=MyISAM AUTO_INCREMENT=23522 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
                

                推荐答案

                唯一比 Using where 更好的是 Using where;将 index 与覆盖索引"一起使用.尝试只选择 uidcreated_date.

                The only thing that would be better than Using where is Using where; Using index with a "covering index". Try selecting just uid and created_date.

                Using where 很好.这意味着它将指定的索引应用于 WHERE 子句并减少返回的行.要摆脱它,您必须摆脱 WHERE 子句.

                Using where is fine. It means it's applying the indicated index to the WHERE clause and reducing the rows returned. To get rid of it, you'd have to get rid of the WHERE clause.

                以下是您应该关注的事项:

                Here are things that you should be concerned about:

                • 使用文件排序
                • 使用临时
                • 未使用索引:EXPLAIN 的 'key' 列中的 NULL 和 'rows' 列中的大量行.
                • Using filesort
                • Using temporary
                • Not using an index: NULL in the 'key' column of the EXPLAIN and a large number of rows in the 'rows' column.

                您的 EXPLAIN 结果表明 MySQL 正在将 index1 应用于 WHERE 子句并返回 2 行:

                Your EXPLAIN result shows that MySQL is applying index1 to the WHERE clause and returning 2 rows:

                1 SIMPLE updates_cats ref index1 index1 8 const 2 100.00 Using where
                

                这篇关于mysql fix 使用 where;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:为什么索引视图不能有 MAX() 聚合? 下一篇:在mysql中使用INDEXES的最大好处是什么?

                相关文章

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

                2. <tfoot id='rCOY6'></tfoot>
                    • <bdo id='rCOY6'></bdo><ul id='rCOY6'></ul>