我有一个关于mysql中的连接和索引的快速问题。table1 name
table1id我使用id和table1id连接table2和table1,我会在table2的table1和table1id中添加id的索引吗?或者我只是向其中一个表中添加一个索引?即时通信工具使用带有MyISAM版本5.x的MySQL
idx_article_taken` (`taken`),) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
mysql> explain SELECT * FROM `article` where taken=0 and processed=0 ORDER BY updated_at----+------------------------------------------------
当我在where子句中使用索引时,我不能理解为什么下面的MySQL查询变慢了。让我抓狂的那一栏叫做删除。该表包含4.8M行。SQL_NO_CACHE SUM(amount)/100 FROM transactions WHERE (type="Payment" or type="Refund") and deleted is NULL
当列是索引时,查询花费的时间略高于11秒,当列没有索引时,查询耗时为3秒,或者当我使用USE INDEX()时,它会告诉优