24

And if I can, any reason (performance/stability) why I shouldn't?

Riedsio
  • 1,377
  • 1
  • 14
  • 18
Nifle
  • 1,472
  • 7
  • 17
  • 30

2 Answers2

18

Note that if your table is using the InnoDB Plugin storage engine (which I highly recommend), if it's a secondary index (almost surely the case), you can still read from the table (i.e. it's non-blocking to SELECT statements).

Riedsio
  • 1,377
  • 1
  • 14
  • 18
16

Yes you can. It will lock the table you're adding an index to while it's being created. If the table is large, it may take awhile as it has to read each row while building the index.

Zach Wily
  • 161
  • 1
  • 2
  • 1
    Facebook has a solution for doing this online. Haven't tried it out myself: https://www.facebook.com/notes/mysql-at-facebook/online-schema-change-for-mysql/430801045932 – esilver Oct 13 '11 at 22:34