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

 

 

Link to comment
Share on other sites

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)

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.