title: Adding index on large table takes forever
body: <p>I have a table (in MySQL) called <code>unused</code> with about 5.4 million rows. The table looks like this:</p>
  
  <pre><code>CREATE TABLE `unused` (
    `id` bigint(20) NOT NULL AUTO_INCREMENT,
    `account_id` bigint(20) DEFAULT NULL,
    `heading_label` varchar(255) NOT NULL,
    `value` varchar(255) NOT NULL,
    `created_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
    `updated_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
    PRIMARY KEY (`id`),
    KEY `fk_account_id` (`account_id`),
    CONSTRAINT `unused_ibfk_1` FOREIGN KEY (`account_id`) REFERENCES `account` (`id`)
  ) ENGINE=InnoDB AUTO_INCREMENT=80524905 DEFAULT CHARSET=latin1
  </code></pre>
  
  <p>I thought queries on this table might go faster if I were to add an index. I tried running this:</p>
  
  <pre><code>create index heading_label
  on unused (heading_label) using btree
  </code></pre>
  
  <p>I let this command run for maybe an hour or two before restarting MySQL. Even though this table has over 5 million rows, it doesn't seem like it should take over an hour to run this sort of thing. But maybe that's normal. I don't really know what I'm doing. Can someone enlighten me?</p>