select does too much work to find rows where primary key does not match

2008-04-15 Thread Patrick J. McEvoy
I have two MyISAM tables; each uses 'phone' as a primary key. Finding rows where the primary keys match is efficient: mysql explain select bar.phone from foo,bar where foo.phone=bar.phone; ++-+---++---+-

Re: select does too much work to find rows where primary key does not match

2008-04-15 Thread Patrick J. McEvoy
I would have thought your not = though is matching a lot more rows every time.. The field is UNIQUE PRIMARY KEY in both tables, so there should be 0 or 1 matches. I would look into using where not exists as a subselect My MySQL book (O'Reilly second edition) does not mention subqueries or