简体   繁体   English

MySQL 在添加新的复合索引时是否获得了表上的锁?

[英]Does MySQL obtains a lock on the table while adding a new composite index?

I have a table on production which is causing performance issues.我有一张导致性能问题的生产表。 I've identified a few quick indexes I can add to resolve the issue.我已经确定了一些可以添加以解决问题的快速索引。 Does MySQL obtains a lock on the table while adding a new index? MySQL 是否在添加新索引时获得了对表的锁定? Does it depend on the nature of index (unique, composite etc)?它是否取决于索引的性质(唯一、复合等)?

Note that I don't have any specific need to add a new column so won't be running any ALTER command.请注意,我没有任何特定需要添加新列,因此不会运行任何ALTER命令。

A UNIQUE index must check for uniqueness. UNIQUE索引必须检查唯一性。

Any change to the PRIMARY KEY requires rebuilding the index.PRIMARY KEY的任何更改都需要重建索引。 (For InnoDB) (对于 InnoDB)

New versions of MySQL can add an index with very little impact.新版本的 MySQL 可以添加索引,影响很小。

Composite does not matter.复合无所谓。

Adding a "new column" is a different question.添加“新列”是一个不同的问题。 This, also, "depends".这也“取决于”。 New versions can do such "instantly" if you don't have the "after" clause.如果您没有“after”子句,新版本可以“立即”执行此操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM