Reputation: 387
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??
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;
Upvotes: 0
Views: 135
Reputation: 15735
Try explain
ing the query. 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;
Upvotes: 0
Reputation: 360
If you haven't added indexes to your temporary table, you should.
Upvotes: 0
Reputation: 50982
Be sure col_name3, col_name4 and col_name has correct indexing, and also, if possible, partritioned by date
Upvotes: 1