[Plugin: Posts 2 Posts] Unnecessarily slow query?
-
Hi scribu!
My site in development has become quite slow in certain situations in which I use P2P. I have analyzed site performance with the WordPress debug bar and found some very slow queries which take ~2.5 seconds each. The slowness is caused by an inner query, which seems unnecessary, because the post ID it’s querying for is already known:
SELECT wp_2_posts.*, wp_2_p2p.* FROM wp_2_posts INNER JOIN wp_2_p2p WHERE 1=1 AND wp_2_posts.post_type IN (‘company’) AND (wp_2_posts.post_status = ‘publish’) AND (wp_2_p2p.p2p_type = ‘company’ AND wp_2_posts.ID = wp_2_p2p.p2p_to AND wp_2_p2p.p2p_from IN (SELECT wp_2_posts.ID FROM wp_2_posts WHERE 1=1 AND wp_2_posts.ID IN (175853) AND wp_2_posts.post_type IN (‘game’) AND (wp_2_posts.post_status = ‘publish’ OR wp_2_posts.post_status = ‘private’) ORDER BY wp_2_posts.post_date DESC )) ORDER BY wp_2_posts.post_date DESC
Replacing the inner query with just the post ID brings the execution time down to only 0.007 seconds! Is this a bug?
- The topic ‘[Plugin: Posts 2 Posts] Unnecessarily slow query?’ is closed to new replies.