MySQL Forums
Forum List  »  Optimizer & Parser

Re: INNER JOIN optimization
Posted by: Rick James
Date: February 23, 2010 11:44PM

Is deptname indexed? Better yet, is it UNIQUE? If so, this might work well:

SELECT  t1.empid,t1.empname,t2.deptname
    from  employees t1
    WHERE  t1.deptid = ( SELECT deptid FROM departments WHERE deptname = 'Sales' )
      AND  t1.empname LIKE 'p%';
But only if employees has
INDEX(deptid, empname)

Options: ReplyQuote


Subject
Views
Written By
Posted
13113
February 22, 2010 12:52AM
Re: INNER JOIN optimization
3851
February 23, 2010 11:44PM
3458
February 27, 2010 01:36PM
3042
February 28, 2010 11:20AM


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.