mysql type all_mysql已经设置主键, 但explain显示key=null, type=all-

mysql type all_mysql已经设置主键, 但explain显示key=null, type=all-在 navicat 里检查 确实 id 已经被设置为主键了 explain 显示 key null type all 问题出在哪 该怎么优化呢 这个是 wordpress 网站 按道理说这里的表和数据库结构都是 wordpress 自动生成的 我这怎么会有这样问题呢 MariaDB jinz gt explain select from

大家好,我是讯享网,很高兴认识大家。

在navicat里检查, 确实id已经被设置为主键了.

explain显示key=null, type=all? 问题出在哪?

该怎么优化呢?

这个是wordpress网站, 按道理说这里的表和数据库结构都是wordpress自动生成的, 我这怎么会有这样问题呢?

MariaDB [jinz]> explain select * from wp_posts;

+------+-------------+----------+------+---------------+------+---------+------+------+-------+

| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |

+------+-------------+----------+------+---------------+------+---------+------+------+-------+

| 1 | SIMPLE | wp_posts | ALL | NULL | NULL | NULL | NULL | 413 | |

+------+-------------+----------+------+---------------+------+---------+------+------+-------+

1 row in set (0.00 sec)

MariaDB [jinz]> explain select * from wp_posts where id =1;

+------+-------------+-------+------+---------------+------+---------+------+------+-----------------------------------------------------+

| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |

+------+-------------+-------+------+---------------+------+---------+------+------+-----------------------------------------------------+

| 1 | SIMPLE | NULL | NULL | NULL | NULL | NULL | NULL | NULL | Impossible WHERE noticed after reading const tables |

+------+-------------+-------+------+---------------+------+---------+------+------+-----------------------------------------------------+

1 row in set (0.00 sec)

wp_posts | CREATE TABLE `wp_posts` (

`ID` bigint(20) unsigned NOT NULL AUTO_INCREMENT,

`post_author` bigint(20) unsigned NOT NULL DEFAULT '0',

`post_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',

`post_date_gmt` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',

`post_content` longtext COLLATE utf8mb4_unicode_ci NOT NULL,

`post_title` text COLLATE utf8mb4_unicode_ci NOT NULL,


讯享网

`post_excerpt` text COLLATE utf8mb4_unicode_ci NOT NULL,

`post_status` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'publish',

`comment_status` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'open',

`ping_status` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'open',

`post_password` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',

`post_name` varchar(200) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',

`to_ping` text COLLATE utf8mb4_unicode_ci NOT NULL,

`pinged` text COLLATE utf8mb4_unicode_ci NOT NULL,

`post_modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',

`post_modified_gmt` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',

`post_content_filtered` longtext COLLATE utf8mb4_unicode_ci NOT NULL,

`post_parent` bigint(20) unsigned NOT NULL DEFAULT '0',

`guid` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',

`menu_order` int(11) NOT NULL DEFAULT '0',

`post_type` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'post',

`post_mime_type` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',

`comment_count` bigint(20) NOT NULL DEFAULT '0',

PRIMARY KEY (`ID`),

KEY `post_name` (`post_name`(191)),

KEY `type_status_date` (`post_type`,`post_status`,`post_date`,`ID`),

KEY `post_parent` (`post_parent`),

KEY `post_author` (`post_author`)

) ENGINE=InnoDB AUTO_INCREMENT=843 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci |

ad1f28e90e937dc4a2761dac70a81abb.png

小讯
上一篇 2025-01-18 10:33
下一篇 2025-04-10 16:34

相关推荐

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/130281.html