2017-07-13 58 views
-1

我的查詢運行更多的則25秒,我不明白優化查詢爲什麼如何使用超過10萬條記錄

SELECT transactions . * , m.member_id, m.group_id, m.username, preffered_currency, transactions.payment_method 
FROM `transactions` 
JOIN `members` `m` ON `m`.`member_id` = `transactions`.`member_id` 
ORDER BY `paid_microtime` 
LIMIT 25 

這裏是交易指數(〜10萬條記錄)表

transactions 0 PRIMARY  1 transaction_id A 92304 NULL NULL  BTREE  
transactions 1 member_id 1 member_id A 44 NULL NULL  BTREE  
transactions 1 payment_method 1 payment_method A 70 NULL NULL  BTREE  
transactions 1 child_method 1 child_method A 234  NULL NULL  BTREE  
transactions 1 check_ballance 1 check_ballance A 2 NULL NULL  BTREE  
transactions 1 transaction_status 1 transaction_status A 18 NULL NULL  BTREE  
transactions 1 dt 1 dt A 92304 NULL NULL  BTREE  
transactions 1 transaction_type 1 transaction_type A 2 NULL NULL  BTREE 
transactions 1 paid_microtime 1 paid_microtime A 92317 NULL NULL  BTREE  

並從成員(30條記錄)表

members  0 PRIMARY  1 member_id A 28 NULL NULL  BTREE  
members  1 username 1 username A 28 NULL NULL  BTREE  
members  1 ban  1 ban  A 4 NULL NULL  BTREE  
members  1 active 1 active A 4 NULL NULL  BTREE 

你能看到我的查詢有什麼問題,這需要25秒嗎?

編輯:從 結果解釋

id select_type  table type possible_keys key  key_len  ref  rows Extra 
1 SIMPLE m ALL  PRIMARY  NULL NULL NULL 28 Using temporary; Using filesort 
1 SIMPLE transactions ref  member_id member_id 4 tadam.m.member_id 2097 Using index condition 
+2

你可以發佈EXPLAIN的結果嗎? –

+1

paid_microtime的索引? – Quazer

+0

@JoeStefanelli請檢查編輯 –

回答

0

這是缺乏RAM的問題。

相關問題