somu.web
somu.web

Reputation: 387

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??

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

Answers (3)

Kaivosukeltaja
Kaivosukeltaja

Reputation: 15735

Try explaining 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

Poodlehat
Poodlehat

Reputation: 360

If you haven't added indexes to your temporary table, you should.

Upvotes: 0

genesis
genesis

Reputation: 50982

Be sure col_name3, col_name4 and col_name has correct indexing, and also, if possible, partritioned by date

Upvotes: 1

Related Questions