title: MySQL table size much larger than size of data in it, causing index scanning queries to be slow
body: <p>I have a table which is inserted into and deleted from at a high rate. The number of rows is never larger than a few hundred and I wouldn't expect it to be larger than a few megabytes, but the table size is 20 gigabytes and growing. It's using MySQL 5.6.35, and the engine is InnoDB. I would expect the inserted rows to be inserted in the space left by the deleted rows, but this doesn't appear to be the case. It grows to this level within a week, and at some point it seems some background process starts, and slowly reduces it by a few gigabytes. </p>
  
  <p>The problem with the table being so large is it causes any queries that scan the whole table like <code>count(*)</code> run very slowly. </p>
  
  <p>Is there something I can change to prevent the table growing like this?</p>