[thelist] MySQL optimization

Steve Lewis nepolon at worlddomination.net
Tue Sep 27 13:37:46 CDT 2005


Anthony Ettinger wrote:

>>Query:
>>  select DISTINCT sectionid
>>  from SectionMembers LEFT JOIN Sections ON
>>      Sections.id=SectionMembers.sectionid
>>  where Sections.instid = '%bindVal01%'
>>

> 
> Have you defined indexes for the fields you're joining
> on?

Long answer: instid and sectionid are foreign keys, id is a primary key.

Short answer: Yes, all three are indexed.

Note:
It looks to me like I don't want a left join, I want an inner join - an 
inner join should prune the result tree further before the where clause 
is applied.  That still doesn't remove my distinct clause, however.  I'm 
still looking for another optimization.

-- 
SteveL


More information about the thelist mailing list