MySQL Forums
Forum List  »  Optimizer & Parser

Re: Three(or Four)-Way Joins
Posted by: Rick James
Date: August 13, 2009 10:34PM

-- FROM (SELECT...) is usually less efficient than JOIN

-- If anything, step 1 is to concentrate on finding the ids needed. Then step 2 is to fetch the thousands of columns needed. That is:
Step 1: CREATE TEMPORARY TABLE tmp (SELECT id FROM ... JOIN ... WHERE ...);
Step 2:
SELECT ...
   FROM tmp
   JOIN data1 ON data1.id = tmp.id
   JOIN ...
Yes, sometimes using a tmp table is optimal.

-- "So is it optimal?" ... to answer that, please provide
* SHOW CREATE TABLE tbl\G
* SHOW TABLE STATUS LIKE 'tbl'\G
* EXPLAIN SELECT ...\G

Options: ReplyQuote


Subject
Views
Written By
Posted
3762
August 11, 2009 07:10PM
2119
August 12, 2009 08:35PM
1864
August 12, 2009 09:31PM
1966
August 13, 2009 12:16AM
1946
August 13, 2009 12:26PM
Re: Three(or Four)-Way Joins
2642
August 13, 2009 10:34PM


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.