Is ‘no_found_rows’ a silver bullet for WP_Query optimization when getting all posts of a certain type?


I’m running a query (200-300 posts), while this might not be for a lot of people / hosts, I just want to optimize wherever I can, given the fact that a lot of things happen when running that particular script, and so, my motivation is optimization.

My query is exactly:

    $args = [
        'post_type' => 'post',
        'orderby' => 'ASC',
        'post__in' => $post_ids

    $headers = new WP_Query( $args );

So I’m asking the database to just give me everything that matches these IDs. But I don’t need any meta information, no paging information, no counting of the posts, nothing, just the raw posts, so I was thinking of adding no_found_rows => true to the query.

While this clearly speeds things up, if I think of all the WP_Query I wrote through my system, I rarely need to know pagination or their count.

Or don’t I? When there’s no pagination, how does the system know to go to the next “batch”?

In other, simpler words: is no_found_rows => true a must-have when querying big lists of posts where you just need to know about all the posts in a given query?

coolpasta 3 years 2020-04-06T20:50:56-05:00 0 Answers 66 views 0

Leave an answer