title: MySQL not using index for BETWEEN query. What am I doing wrong?
body: <p>I've tried different variations of this query but I just can't get it to use the timestamp index. What am I doing wrong?</p>
  
  <p>Any help will be greatly appreciated :)</p>
  
  <hr>
  
  <pre><code>MariaDB [alienvault]&gt; explain extended SELECT * FROM alienvault_siem.acid_event WHERE (timestamp BETWEEN '2012-10-09 11:20:17' AND '2012-10-10 03:20:17');
  +------+-------------+------------+------+---------------+------+---------+------+---------+----------+-------------+
  | id   | select_type | table      | type | possible_keys | key  | key_len | ref  | rows    | filtered | Extra       |
  +------+-------------+------------+------+---------------+------+---------+------+---------+----------+-------------+
  |    1 | SIMPLE      | acid_event | ALL  | timestamp     | NULL | NULL    | NULL | 4481579 |    50.00 | Using where |
  +------+-------------+------------+------+---------------+------+---------+------+---------+----------+-------------+
  1 row in set, 1 warning (0.01 sec)
  </code></pre>
  
  <p>Table structure:</p>
  
  <pre><code>CREATE TABLE IF NOT EXISTS `acid_event` (
    (...)
    `timestamp` datetime NOT NULL,
    (...)
    PRIMARY KEY (`id`),
    (...)
    KEY `timestamp` (`timestamp`),
    (...)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  </code></pre>
  
  <p>Software: Percona Server</p>
  
  <p>Software version: 5.5.27-28.1 - Percona Server (GPL), Release 28.1</p>