开发者

MySQL is doing a full table screen

I am trying to figure out why the following SQL has a type of ALL for the categories c table.

EXPLAIN SELECT
 t.todo_id,
开发者_如何学C t.name todo_name,
 c.name category_name
FROM
 todos t,
 categories c
WHERE t.category_id = c.category_id

The todos table has an index on category_id and todo_id is a primary key. The category_id column in the categories table is a primary key.

The EXPLAIN lists PRIMARY as a possible key for the categories table but it isn't using it.

Thanks.


It's simple. Your query selects all data from your tables. If you add the WHERE statement everything be fine.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜