【问题标题】:InnoDB, how to detect the index types?InnoDB,如何检测索引类型?
【发布时间】:2014-05-13 14:35:19
【问题描述】:

我有一张桌子:

CREATE TABLE  `posts` (
  `post_id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `topic_id` mediumint(8) unsigned NOT NULL DEFAULT '0',
  `forum_id` mediumint(8) unsigned NOT NULL DEFAULT '0',
  `poster_id` mediumint(8) unsigned NOT NULL DEFAULT '0',
  `icon_id` mediumint(8) unsigned NOT NULL DEFAULT '0',
  `poster_ip` varchar(40) COLLATE utf8_bin NOT NULL DEFAULT '',
  `post_time` int(11) unsigned NOT NULL DEFAULT '0',
  `post_approved` tinyint(1) unsigned NOT NULL DEFAULT '1',
  `post_reported` tinyint(1) unsigned NOT NULL DEFAULT '0',
  `enable_bbcode` tinyint(1) unsigned NOT NULL DEFAULT '1',
  `enable_smilies` tinyint(1) unsigned NOT NULL DEFAULT '1',
  `enable_magic_url` tinyint(1) unsigned NOT NULL DEFAULT '1',
  `enable_sig` tinyint(1) unsigned NOT NULL DEFAULT '1',
  `post_username` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT '',
  `post_subject` blob,
  `post_text` mediumtext COLLATE utf8_bin NOT NULL,
  `post_checksum` varchar(32) COLLATE utf8_bin NOT NULL DEFAULT '',
  `post_attachment` tinyint(1) unsigned NOT NULL DEFAULT '0',
  `bbcode_bitfield` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT '',
  `bbcode_uid` varchar(8) COLLATE utf8_bin NOT NULL DEFAULT '',
  `post_postcount` tinyint(1) unsigned NOT NULL DEFAULT '1',
  `post_edit_time` int(11) unsigned NOT NULL DEFAULT '0',
  `post_edit_reason` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT '',
  `post_edit_user` mediumint(8) unsigned NOT NULL DEFAULT '0',
  `post_edit_count` smallint(4) unsigned NOT NULL DEFAULT '0',
  `post_edit_locked` tinyint(1) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`post_id`),
  KEY `forum_id` (`forum_id`),
  KEY `topic_id` (`topic_id`),
  KEY `poster_ip` (`poster_ip`),
  KEY `poster_id` (`poster_id`),
  KEY `post_approved` (`post_approved`),
  KEY `post_username` (`post_username`),
  KEY `tid_post_time` (`topic_id`,`post_time`) USING HASH
) ENGINE=InnoDB AUTO_INCREMENT=22381 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

如您所见,最后一个索引是“USING HASH” - 但是当我使用 show indexes from posts; 时,它并没有显示出来

【问题讨论】:

    标签: mysql


    【解决方案1】:

    在快速Google search 之后,我很快找到了InnoDB doesn't support HASH indexes,但仍然接受表定义中的修饰符。

    SHOW CREATE TABLE 可能会显示 USING HASH,但 SHOW INDEXES 实际上会显示正在使用的索引类型:

    Index_type

    使用的索引方法(BTREEFULLTEXTHASHRTREE)。

    【讨论】:

    • 这是最有趣的部分:显示索引不会显示。我只是标记“BTREE”
    猜你喜欢
    • 2011-06-06
    • 2013-07-06
    • 2012-03-20
    • 2021-07-07
    • 2020-04-21
    • 2010-10-13
    • 2012-09-23
    • 2015-05-12
    • 1970-01-01
    相关资源
    最近更新 更多