我现在被困了一段时间,Select_full_join 数字不断增加。
我正在使用“log-queries-not-using-indexes”,我查看了 mysql-slow.log,发现了很多这样的查询:
# Time: 131106 16:44:51
# User@Host: XXX @ localhost []
# Query_time: 0.000497 Lock_time: 0.000061 Rows_sent: 1 Rows_examined: 0
SET timestamp=1383752691;
SELECT COUNT(*) AS expression
FROM
(SELECT 1 AS expression
FROM
com_c_jobs_listing cj
WHERE (category IN ('Operations', 'Business Development', 'Sales/Account Management', 'R&D', 'Internal IT')) AND (country IN ('Brazil', 'China', 'France', 'Germany', 'Italy', 'Japan', 'Korea', 'Netherlands', 'Russia', 'United Kingdom', 'United States')) ) subquery;
我不明白为什么要记录此内容。 此外,还有类别和国家/地区的索引。
我想我错过了一些东西,但我找不到什么......
这是解释查询的结果:
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away 2 DERIVED cj range category,country category 302 NULL 86 Using where
我该怎么办?有什么想法吗?
最佳答案
根据您的解释扩展(此处截断):
id select_type possible_keys key key_len
1 PRIMARY NULL NULL NULL
2 DERIVED category,country category 302
您可以看到正在为派生子查询选择一个键,但您的父查询依赖于派生表,因此未建立索引(没有可能的键)。
为什么你有一个子查询而不直接计算行数?
SELECT COUNT(*) AS expression
FROM com_c_jobs_listing cj
WHERE category IN ('Operations',
'Business Development', 'Sales/Account
Management', 'R&D', 'Internal IT')
AND country IN ('Brazil', 'China', 'France',
'Germany', 'Italy', 'Japan', 'Korea', 'Netherlands',
'Russia', 'United Kingdom', 'United States');
关于mysql - select_full_join数量不断增加,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19819016/