MySQL Forums
Forum List  »  Performance

Re: Join Order and performance
Posted by: scott cornwell
Date: March 29, 2006 03:16PM

I spent the day playing with this and I turned on the log_slow_queries - one thing i did discover for the following when these tables are large is the order does matter (using mysql 4.1)

Examining the slow_log, Switching the order makes a HUGE difference where the first example shows that maybe 1654032 rows are examined in 122 seconds - switching this then shows that only 434211 rows were examined in like 8 seconds


> for example would
> SELECT T1.*, T2.*, T3.* FROM T1
> LEFT JOIN T2 ON T1.id = T2.id
> LEFT JOIN T3 ON T1.id = T3.id
> WHERE ......
>
> be any major difference than the following (T3 is
> joined on first)
> SELECT T1.*, T2.*, T3.* FROM T1
> LEFT JOIN T3 ON T1.id = T3.id
> LEFT JOIN T2 ON T1.id = T2.id
> WHERE ......

Options: ReplyQuote


Subject
Views
Written By
Posted
8286
March 28, 2006 12:37PM
Re: Join Order and performance
2359
March 29, 2006 03:16PM


Sorry, you can't reply to this topic. It has been closed.

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.