Jump to content

[SOLVED] Query Performance


charafantah

Recommended Posts

I have this SQL Query that takes 10-15 minutes to execute, is there a better way to write so i can minimize execution time?

SELECT ttemp.t24no, ttemp.subasset,ttemp.description,ttemp.inputter,ttemp.authoriser,temp.telekurs,temp.price,ttemp.price,ttemp.sxc,ttemp.pdate,temp.pdate,temp.ccy
FROM temp
INNER JOIN ttemp
ON temp.telekurs=ttemp.telekurs and temp.sxc=ttemp.sxc and temp.ccy=ttemp.ccy and temp.price<>ttemp.price

 

The average rows in temp is 100,000 rows and average rows on ttemp is 20,000 rows

 

Thanks,

 

Link to comment
https://forums.phpfreaks.com/topic/171654-solved-query-performance/
Share on other sites

thats the result of the explain:

+----+-------------+-------+------+---------------+------+---------+------+-----
--+--------------------------------+
| id | select_type | table | type | possible_keys | key  | key_len | ref  | rows
  | Extra                          |
+----+-------------+-------+------+---------------+------+---------+------+-----
--+--------------------------------+
|  1 | SIMPLE      | ttemp | ALL  | NULL          | NULL | NULL    | NULL | 1594
5 |                                |
|  1 | SIMPLE      | temp  | ALL  | NULL          | NULL | NULL    | NULL | 9884
9 | Using where; Using join buffer |
+----+-------------+-------+------+---------------+------+---------+------+-----
--+--------------------------------+
2 rows in set (0.19 sec)

 

 

i expect the result to be around 100 rows...nope the column are not indexed....i dont have any unique thing to index (is it still possible to do it? :S)

 

 

WOW!!! i guess i should RTFM! :D  after putting the indexes, the query takes 1.5 seconds!!!  :D thanks guys

 

here's the explain:

+----+-------------+-------+------+------------------------------+----------+---
------+-------------------+-------+-------------+
| id | select_type | table | type | possible_keys                | key      | ke
y_len | ref               | rows  | Extra       |
+----+-------------+-------+------+------------------------------+----------+---
------+-------------------+-------+-------------+
|  1 | SIMPLE      | temp  | ALL  | telekurs,ccy,sxc,ccy_2,sxc_2 | NULL     | NU
LL    | NULL              | 98849 |             |
|  1 | SIMPLE      | ttemp | ref  | ccy,sxc,telekurs             | telekurs | 17
      | t24.temp.telekurs |     1 | Using where |
+----+-------------+-------+------+------------------------------+----------+---
------+-------------------+-------+-------------+
2 rows in set (0.00 sec)

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.