MySQL Forums
Forum List  »  Optimizer & Parser

EXPLAIN Table reference order
Posted by: Sunil H
Date: May 27, 2009 01:06AM

Hi,
I have two cases for Explain. I have added additional where condition [AND T2.city='Banglore'] in the case 2 and I want to know why the order of table reference gets changed in the case 2.

CASE 1:
EXPLAIN select count(*) from exp1 AS T1 JOIN exp2 AS T2 ON T1.ip=T2.ip WHERE (T1.severity LIKE ('critical%') AND (T2.main="All" OR T2.state="All" OR T2.city="All" OR T2.ip="All")) \G
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: T1
type: range
possible_keys: ip,severity
key: severity
key_len: 258
ref: NULL
rows: 1
Extra: Using where
*************************** 2. row ***************************
id: 1
select_type: SIMPLE
table: T2
type: ref
possible_keys: state,city,ip,main
key: ip
key_len: 258
ref: telsimaDB1_3.T1.ip
rows: 2
Extra: Using where
2 rows in set (0.00 sec)
----------------------------------------------------------------------------------

CASE 2:
explain select count(*) from exp1 AS T1 JOIN exp2 AS T2 ON T1.ip=T2.ip WHERE (T1.severity LIKE ('critical%') AND (T2.main="All" OR T2.state="All" OR T2.city="All" OR T2.ip="All") AND T2.city='Banglore') \G
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: T2
type: ref
possible_keys: state,city,ip,main
key: city
key_len: 258
ref: const
rows: 1
Extra: Using where
*************************** 2. row ***************************
id: 1
select_type: SIMPLE
table: T1
type: ref
possible_keys: ip,severity
key: ip
key_len: 258
ref: telsimaDB1_3.T2.ip
rows: 2
Extra: Using where
2 rows in set (0.00 sec)



Thanks,
Sunil

Options: ReplyQuote


Subject
Views
Written By
Posted
EXPLAIN Table reference order
4828
May 27, 2009 01:06AM
2302
May 28, 2009 07:10PM


Sorry, you can't reply to this topic. It has been closed.
This forum is currently read only. You can not log in or make any changes. This is a temporary situation.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.