4 Fatal Mistakes That Are Making Your Queries Slow

Use WP_Query or
get_posts

  • `no_found_rows` (removes SQL_CALC_FOUND_ROWS)
  • `update_post_term_cache`
  • `update_post_meta_cache`
  • `fields`

Avoid post__not_in

  • Adds `AND ID not in ('12345')
  • Automatically skips cache on every page the query exists
  • Adds unique query to cache on every page the query exists

Avoid meta queries

  • meta is not index and is unique to each post
  • use a taxonomy if you need to group posts together

Avoid complex queries

  • less tables queried, the better
  • use PHP to filter out unwanted results

deck

By Alex Young

deck

  • 314