Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
MySQL正在做一个全表屏幕_Mysql_Join_Indexing_Explain - Fatal编程技术网

MySQL正在做一个全表屏幕

MySQL正在做一个全表屏幕,mysql,join,indexing,explain,Mysql,Join,Indexing,Explain,我试图弄明白为什么下面的SQL对于categories c表有一个ALL类型 EXPLAIN SELECT t.todo_id, t.name todo_name, c.name category_name FROM todos t, categories c WHERE t.category_id = c.category_id todo表在category\u id上有一个索引,todo\u id是主键。 类别表中的category\u id列是主键 EXPLAIN列出了PRIM

我试图弄明白为什么下面的SQL对于categories c表有一个ALL类型

EXPLAIN SELECT
 t.todo_id,
 t.name todo_name,
 c.name category_name
FROM
 todos t,
 categories c
WHERE t.category_id = c.category_id
todo
表在
category\u id
上有一个索引,
todo\u id
是主键。 类别表中的
category\u id
列是主键

EXPLAIN
列出了
PRIMARY
作为categories表的可能键,但它没有使用它


谢谢。

很简单。查询从表中选择所有数据。如果添加WHERE语句,一切都会好起来。

我尝试了Jean-Louis的SQL,但类型仍然是所有可能的\u键都列为主。好的,我将对它进行一些讨论,因为我有一堆where/and子句,但我没有将它们包括在示例中,因为它要长得多。我创建了一个测试数据库,包括您的表,并对其进行了测试。一切正常。别在意。如果包含WHERE语句,则类型为“const”。可能问题是你没有在这里发布你的声明。