[英]Speeding up the query execution
我有從數以百萬計的記錄表中提取出數千行到temp表,即使在temp表上查詢很簡單,要花幾個小時才能得到結果,是否知道我可以如何加快查詢處理時間?
查詢是這樣的
Select col_name col1, col_name2 col2 from tbl_temp where col_name3 = 'value' and
col_name4 = 'value' order by col_name desc limit 2;
確保col_name3,col_name4和col_name具有正確的索引編制,並在可能的情況下,按日期進行分區
如果尚未將索引添加到臨時表,則應該這樣做。
嘗試explain
查詢。 它將為您提供有關如何執行查詢的大量信息,包括查詢必須經過多少行以及是否可以使用索引。
EXPLAIN Select col_name col1, col_name2 col2 from tbl_temp where col_name3 = 'value' and col_name4 = 'value' order by col_name desc limit 2;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.