title: MySQL Index is bigger than the data stored
body: <p>I have a database with the following stats</p>
  
  <pre><code>Tables     Data   Index   Total
  11     579,6 MB  0,9 GB  1,5 GB
  </code></pre>
  
  <p>So as you can see the Index is close to 2x bigger. And there is one table with ~7 million rows that takes up at least 99% of this.</p>
  
  <p>I also have two indexes that are very similar</p>
  
  <pre><code>a) UNIQUE KEY `idx_customer_invoice` (`customer_id`,`invoice_no`),
  b) KEY `idx_customer_invoice_order` (`customer_id`,`invoice_no`,`order_no`)
  </code></pre>
  
  <p><strong>Update</strong>: Here is the table definition (at least structurally) of the largest table</p>
  
  <pre><code>CREATE TABLE `invoices` (
    `id` int(10) unsigned NOT NULL auto_increment,
    `customer_id` int(10) unsigned NOT NULL,
    `order_no` varchar(10) default NULL,
    `invoice_no` varchar(20) default NULL,
    `customer_no` varchar(20) default NULL,
    `name` varchar(45) NOT NULL default '',
    `archived` tinyint(4) default NULL,
    `invoiced` tinyint(4) default NULL,
    `time` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
    `group` int(11) default NULL,
    `customer_group` int(11) default NULL,
    PRIMARY KEY  (`id`),
    UNIQUE KEY `idx_customer_invoice` (`customer_id`,`invoice_no`),
    KEY `idx_time` (`time`),
    KEY `idx_order` (`order_no`),
    KEY `idx_customer_invoice_order` (`customer_id`,`invoice_no`,`order_no`)
  ) ENGINE=InnoDB AUTO_INCREMENT=9146048 DEFAULT CHARSET=latin1 |
  </code></pre>
  
  <p><strong>Update 2</strong>:</p>
  
  <pre><code>mysql&gt; show indexes from invoices;
  +----------+------------+----------------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
  | Table    | Non_unique | Key_name                   | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment |
  +----------+------------+----------------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
  | invoices |          0 | PRIMARY                    |            1 | id          | A         |     7578066 |     NULL | NULL   |      | BTREE      |         |
  | invoices |          0 | idx_customer_invoice       |            1 | customer_id | A         |          17 |     NULL | NULL   |      | BTREE      |         |
  | invoices |          0 | idx_customer_invoice       |            2 | invoice_no  | A         |     7578066 |     NULL | NULL   | YES  | BTREE      |         |
  | invoices |          1 | idx_time                   |            1 | time        | A         |      541290 |     NULL | NULL   |      | BTREE      |         |
  | invoices |          1 | idx_order                  |            1 | order_no    | A         |        6091 |     NULL | NULL   | YES  | BTREE      |         |
  | invoices |          1 | idx_customer_invoice_order |            1 | customer_id | A         |          17 |     NULL | NULL   |      | BTREE      |         |
  | invoices |          1 | idx_customer_invoice_order |            2 | invoice_no  | A         |     7578066 |     NULL | NULL   | YES  | BTREE      |         |
  | invoices |          1 | idx_customer_invoice_order |            3 | order_no    | A         |     7578066 |     NULL | NULL   | YES  | BTREE      |         |
  +----------+------------+----------------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
  </code></pre>
  
  <p><strong>My questions are:</strong></p>
  
  <ol>
  <li>Is there a way to find unused indexes in MySQL?</li>
  <li>Are there any common mistakes that impact the size of the index?</li>
  <li>Can indexA safely be removed?</li>
  <li>How can you measure the size of each index? All I get is the total of all indexes.</li>
  </ol>