简体   繁体   English

加快查询执行

[英]Speeding up the query execution

I have table with millions of record from am extracting some thousands of rows to temp table even if query on temp table with simple where it is taking hours to get me the result , does any know how i can speed up query processing time?? 我有从数以百万计的记录表中​​提取出数千行到temp表,即使在temp表上查询很简单,要花几个小时才能得到结果,是否知道我可以如何加快查询处理时间?

Query is something like this 查询是这样的

 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具有正确的索引编制,并在可能的情况下,按日期进行分区

如果尚未将索引添加到临时表,则应该这样做。

Try explain ing the query. 尝试explain查询。 It will give you lots of information about how the query is executed, including how many rows it has to go through and whether or not it can use indexes. 它将为您提供有关如何执行查询的大量信息,包括查询必须经过多少行以及是否可以使用索引。

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM