List:General Discussion« Previous MessageNext Message »
From:tmarly Date:April 15 2008 9:03am
Subject:Re: Two MySql servers, but very different performances for a SELECT JOIN
View as plain text  
I'm still trying to decript the EXPLAIN result, and there is something I really
don't understand:

mysql> EXPLAIN SELECT STRAIGHT_JOIN media.* FROM country,content,media WHERE
country.id='Germany' AND country.detail_tid=content.tid AND
content.id=media.content_id;

On the FAST server:

+--+-------+-----+----------+----------+----+----------+----+
|id|table  |type |possible_k|key       |k_le|ref       |rows|
+--+-------+-----+----------+----------+----+----------+----+
|1 |country|const|PRIMARY   |PRIMARY   |383 |const     |   1|
|1 |content|ALL  |PRIMARY   |NULL      |NULL|NULL      | 137|
|1 |media  |ref  |media_FI_2|media_FI_2|5   |content.id| 248|
+--+-------+-----+----------+----------+----+----------+----+

On the SLOW server:
+--+-------+-----+----------+----------+----+----------+------+
|id|table  |type |possible_k|key       |k_le|ref       | rows |
+--+-------+-----+----------+----------+----+----------+------+
|1 |country|ref  |PRIMARY   |PRIMARY   |383 |const     |     1|
|1 |content|ALL  |PRIMARY   |NULL      |NULL|NULL      |   137|
|1 |media  |ALL  |media_FI_2|NULL      |NULL|NULL      |125649|
+--+-------+-----+----------+----------+----+----------+------+

On the 3rd row, on the fast server, type=ref, and ref points toward the
content.id column.

And on the slow server, type=ALL, and ref points to NULL. Since my MySql schema
defines explicitly the foreign key, should'n I have 'content.id' instead of
'NULL' ?

What is the difference between 'possible_key' and 'key' columns ? why key=NULL
on my slow server ?

 Tristan

-- 
Tristan Marly
http://www.linkedin.com/in/tristanmarly
Thread
Two MySql servers, but very different performances for a SELECT JOINtmarly11 Apr
  • Re: Two MySql servers, but very different performances for a SELECT JOINRob Wultsch11 Apr
  • Re: Two MySql servers, but very different performances for a SELECTJOINTristan Marly13 Apr
    • Re: Two MySql servers, but very different performances for a SELECTJOINSebastian Mendel14 Apr
Re: Two MySql servers, but very different performances for a SELECT JOINtmarly15 Apr
  • Re: Two MySql servers,but very different performances for a SELECT JOINWm Mussatto15 Apr
    • Re: Two MySql servers, but very different performances for a SELECT JOINRob Wultsch15 Apr
  • Re: Two MySql servers, but very different performances for a SELECT JOINtmarly16 Apr
    • Re: Two MySql servers, but very different performances for a SELECT JOINRob Wultsch16 Apr
      • Re: Two MySql servers, but very different performances for a SELECT JOINtmarly16 Apr