optimization - Mysql long subquery "in" issue -


i can't understand issue in simple mysql query. here, pls

select sql_no_cache     id,     post_title,     post_type wp_posts  1   , (wp_posts.id in (select id ...[complex subquery here]...)) 

this query running quite long (2.5 sec), if running subquery separately (that 1 goes "in (..") takes 0.15 sec only. subquery returning 60 rows , think whole query have run faster in case.

btw i've tried run whole query fixed id list instead of subquery, like

select sql_no_cache     id,     post_title,     post_type wp_posts  1 , (wp_posts.id in ( 48393, 52796, .... 58 more numbers)) 

and working fast (~1 ms).

where issue? why whole query running slow , how can improve this? thanks.

as mentioned above, mysql not great @ optimizing queries in kind of situation. happening it's doing subquery once every record in wp_posts. avoid behavior combining them single query join

select sql_no_cache     id,     post_title,     post_type wp_posts left join another_table on wp_posts.id = another_table.post_id {complex conditions other query} 

hope helpful


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -