MySQL 仍然以这种方式处理索引吗?

JIS*_*one 8 mysql myisam performance index

在 MySQL 中删除重复索引需要很长时间,所以在我等待的时候,我搜索了它并找到了 2006 年的这篇文章,谈论 MySQL 如何处理ADDDROP索引。

如果表 T 是具有四个索引(ndx1、ndx2、ndx3、ndx4)的 MySQL 表,并且您想“更改表 T 删除索引 ndx3;” 这正是幕后发生的事情:

1) MySQL 将 T.MYD 复制到临时表,即 S.MYD 和零字节 S.MYI。2) MySQL 确实 'alter table S add index ndx1 (...); 3) MySQL 确实 'alter table S add index ndx2 (...); 4) MySQL 'alter table S add index ndx4 (...); 5) MySQL 删除 T.MYD 并删除 T.MYI 6) MySQL 将 S.MYD 重命名为 T.MYD,并将 S.MYI 重命名为 T.MYI

这仍然是真的吗?他的建议是否仍然有效?

给定具有四个索引(ndx1、ndx2、ndx3、ndx4)的同一个 MyISAM 表 T 并且您想“更改表 T 删除索引 ndx3;” 试试这个:

1)像T一样创建表T1;这将创建一个带有索引 ndx1、ndx2、ndx3 和 ndx4 的空表 T1。2) 更改表 T1 删除索引 ndx3;这会在空 T1 上删除索引 ndx3,这应该是瞬时的。3) 插入T1 select * from T; 这将填充表 T 并一次性加载 T1 的所有三 (3) 个索引。4)删除表表T;5) 将表 T1 重命名为 T;

你们都是如何处理从大表中添加和删除索引的?

Rol*_*DBA 16

这就是 MySQL 4.x 这样做的方式,它曾经严重地激怒了我。

事实上,我有一个公式计算需要多少这样的指数操作

Table with 0 indexes and adding 1 index tooks 1 temp table
Table with 1 index   and adding 1 index tooks 3 temp tables
Table with 2 indexes and adding 1 index tooks 6 temp tables
Table with 3 indexes and adding 1 index tooks 10 temp tables (I had eyewitnessed this !!!)
.
.
.
Table with n indexes and adding 1 index took (n + 1) X (n + 2) / 2 temp tables
.
.
.
Table with 16 indexes and adding 1 index took 153 temp tables
Run Code Online (Sandbox Code Playgroud)

好消息,MySQL 5.x 没有这样做!!!

如果 MySQL 5.x 做到了这一点,我今天将成为 PostgreSQL DBA(没有冒犯 PostgreSQL,它本身就是一个出色的 RDBMS)。

更新

天啊,我看了帖子!!!那个帖子是我发的!!!

我从没想过有人会挖这个帖子。

请让这样的东西死而复生。现在我有闪回!!!