title: Mysql: Deadlock found when trying to get lock, need remove key?
body: <p>i count page view statistics in Mysql and sometimes get deat lock.</p>
  
  <p>How can resolve this problem? Maybe i need remove one of key?</p>
  
  <p>But what will happen with reading performance? Or is it not affect?</p>
  
  <p>Table:</p>
  
  <pre><code>CREATE TABLE `pt_stat` (
    `stat_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
    `post_id` int(11) unsigned NOT NULL,
    `stat_name` varchar(50) NOT NULL,
    `stat_value` int(11) NOT NULL DEFAULT '0',
    PRIMARY KEY (`stat_id`),
    KEY `post_id` (`post_id`),
    KEY `stat_name` (`stat_name`)
  ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8
  </code></pre>
  
  <p>Error: "Deadlock found when trying to get lock; try restarting transaction".</p>
  
  <pre><code>UPDATE pt_stat SET stat_value = stat_value + 1 WHERE post_id = "21500" AND stat_name = 'day_20170111';
  </code></pre>