SELECT  t.*, tt.* FROM wp_terms AS t  INNER JOIN wp_term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('post_tag') AND tt.count > 0 ORDER BY t.name ASC;

Query_time: 3.445370

  • How many tags do you have? – Jacob Peattie Jan 18 at 12:52
  • Almost 55,470 tags – Arbab Jan 18 at 14:33
  • Well that’s why. Not much you can do to optimise a query for 50k+ records. Where is this query coming from? – Jacob Peattie Jan 18 at 14:46
  • @JacobPeattie that's the issue. checked my theme code, it's not there. But running timely on the server. – Arbab Jan 18 at 14:50
  • I can find several such SQL statements, originating from wp-includes/class-wp-term.php, wp-includes/class-wp-term-query.php and wp-includes/taxonomy.php in a 5.0.3 installation of WP. – Jos Jan 18 at 16:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.