Theme 259514 2.0440
SELECT wp_posts.ID FROM wp_posts LEFT JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) WHERE 1=1 AND wp_posts.ID NOT IN (391534) AND ( wp_term_relationships.term_taxonomy_id IN (2,516296,517375,517376,517377,517378,517554,517555,517572,517573,517632,517633,517634,517635,517636,517699,517707,517708,517750,517754,524858,524859,524915,524916,524917,524918,524919,524999,525001,525064,525065,525185,525186,525187,525519,525520,525523,525524,525582,525841,533395,533416,533453,535782,535783,535784,535829,536343,549563,549564,549565,549586,550302,550518,550724,555654,702393,702713,704994,705119,705305,705306,705307,772366,772367,920642,939122,991853) ) AND wp_posts.post_type = 'post' AND ((wp_posts.post_status = 'publish')) GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 6
How can I improve this query ? I have many posts and they are taking like 2secs each.
I also found this extra info that I think would help...
Why do you think modifying WordPress core table is a good idea? – Krzysiek Dróżdż♦ Jun 12 '15 at 4:21 I really don't think it's a good idea but a necessary one if running wordpress with the amount of posts and combined with the limitations of mysql not having a descending index function. Those file sorts caused by the order by operations are a deal breaker for us in regards to site performance. – Ranknoodle Jun 15 '15 at 2:34 But these operations are slow since you're doing it wrong. In some projects we had similar issue, but came to very different solution, that didn't modify core tables. We've created our own table and used it as indexing/search table. So every slow query was searching only based on this one table (no joins needed). (And we had much more data, AFAIR) – Krzysiek Dróżdż♦ Jun 15 '15 at 5:06 Hi KRZYSIEK can you explain a little more on indexing search tables that you created? For example the slow query outline in the original question, I would create a table to store the post ID,reverse_post_id,post_type etc and only query against that? – Ranknoodle Jun 15 '15 at 16:31 Send me an e-mail, I'll try to elaborate on that method. – Krzysiek Dróżdż♦ Jun 15 '15 at 16:34
But no idea on the method he used.