我想避免在此查询的解释计划temporary table
:避免临时表中说明计划
http://sqlfiddle.com/#!2/544dd/1
EXPLAIN SELECT count(p2m.product_id) AS total, p2m.merchant_id
FROM merchants_to_products p2m
LEFT JOIN products p ON p2m.id = p2m.product_id
GROUP BY p2m.merchant_id
ORDER BY total DESC
| ID | SELECT_TYPE | TABLE | TYPE | POSSIBLE_KEYS | KEY | KEY_LEN | REF | ROWS | EXTRA |
|----|-------------|-------|-------|---------------|------------|---------|--------|------|----------------------------------------------|
| 1 | SIMPLE | p2m | index | (null) | product_id | 8 | (null) | 11 | Using index; Using temporary; Using filesort |
| 1 | SIMPLE | p | index | (null) | PRIMARY | 4 | (null) | 10 | Using index |
什么临时表? – Shaeldon 2014-10-02 12:12:31
@Shaeldon:我认为他在解释结果的第一行中提到了“Using temporary”。 – 2014-10-02 12:13:52
哪个是原始表格,哪个是临时的?!!!!!!!!!!!!!!!!! – nesreen 2014-10-02 12:16:29