TOOLGEIST ↗
213 EDITIONS

ACQUISITION & LICENSING DESK

Direct Foundry Enquiry

Specify your target edition or studio requirements. We respond within one business day with direct source archive delivery and licensing credentials.

Performance November 3, 2026 256 words · 2 min read

WordPress WP_Query Optimization: no_found_rows, fields => ids & Caching Heavy Loops

WordPress WP_Query Optimization: no_found_rows, fields => ids & Caching Heavy Loops
Cut SQL query overhead in custom WordPress loops by skipping SQL_CALC_FOUND_ROWS, disabling term/meta caches when unused, and caching IDs.

1. The Hidden Pagination Tax Inside Every Default WP_Query

By default, whenever you instantiate new WP_Query( array( "posts_per_page" => 6 ) ) for a homepage “Featured Work” or “Latest Posts” block, WordPress silently instructs MySQL to count every matching row in the entire table (SQL_CALC_FOUND_ROWS) just in case you render pagination links. On a site with 20,000 posts, that unnecessary count slows down every homepage render.

Whenever a query does not render pagination, pass "no_found_rows" => true. If your loop does not inspect post meta or categories, also set "update_post_meta_cache" => false and "update_post_term_cache" => false to skip extra follow-up queries completely.

Precision mechanical assembly
Fig 01. Passing no_found_rows => true eliminates unnecessary full-table row counting on non-paginated blocks.
$featured = new WP_Query( array(
    'post_type'              => 'post',
    'posts_per_page'         => 6,
    'no_found_rows'          => true,
    'update_post_meta_cache' => false,
    'update_post_term_cache' => false,
) );

2. Avoiding query_posts() & Caching Expensive Taxonomy Queries

Never call query_posts() in WordPress templates—it mutates the global main query and breaks pagination state. Always instantiate a dedicated new WP_Query() and call wp_reset_postdata() immediately after the loop closes.

For complex homepage grids or archive counters that rarely change, store the computed array inside a transient (set_transient( "kiln_archive_index", $data, HOUR_IN_SECONDS )) and invalidate it cleanly on save_post.

FAQ — How much faster is no_found_rows => true? On tables with 10,000+ posts, skipping SQL_CALC_FOUND_ROWS routinely cuts query time by 30–60%.