我只是通過記錄緩慢查詢和EXPLAIN
來優化查詢。我想的是...我不知道到底是什麼樣的東西,我應該尋找....我有查詢幫助優化簡單的MySQL查詢
SELECT DISTINCT
screenshot.id,
screenshot.view_count
FROM screenshot_udb_affect_assoc
INNER JOIN screenshot ON id = screenshot_id
WHERE unit_id = 56
ORDER BY RAND()
LIMIT 0, 6;
看着這兩個要素....我應該在那裏專注於優化?
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE screenshot ALL PRIMARY NULL NULL NULL 504 Using temporary; Using filesort
1 SIMPLE screenshot_udb_affect_assoc ref screenshot_id screenshot_id 8 source_core.screenshot.id,const 3 Using index; Distinct
哪些列來自查詢中的哪個表? – 2010-11-07 04:28:44
他們來自'screenshot' – Webnet 2010-11-07 04:31:11
'unit_id'呢? – 2010-11-07 04:34:41