MySQL Forums
Forum List  »  General

Re: Sub Query is Very Slow
Posted by: Peter Brawley
Date: December 03, 2011 01:38PM

Depending on your MySQL version IN() is slow or slower, see "The unbearable slowness of IN()" at http://www.artfulsoftware.com/queries.php.

A join will perform faster, though yours won't work without revision since 'inner' and 'outer' are MySQL reserved words.

A join will still be slow if the table's indexes aren't adequate. To find out, run ...

EXPLAIN EXTENDED
select o.articlenumber 
from temp_tag as o
LEFT JOIN temp_tag AS i 
  ON o.articlenumber=i.cont 
  and i.heading is not null
  and i.heading <> '' 
  and i.publishdate='2011-10-20'
  and i.type = 'story' 
  and i.cont <> 0
WHERE i.cont IS NULL;

in the mysql client, and post the result here inside BBCode code tags for human readability.

PB

Options: ReplyQuote


Subject
Written By
Posted
December 02, 2011 11:33PM
Re: Sub Query is Very Slow
December 03, 2011 01:38PM
December 04, 2011 10:52PM
December 05, 2011 02:30AM
December 05, 2011 03:15AM
December 05, 2011 11:44PM
December 05, 2011 11:48PM
December 06, 2011 02:13AM


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.