WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 21 months ago

#17195 closed enhancement (invalid)

Lazy load $wp_query->found_posts

Reported by: scribu Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Query Keywords:
Focuses: Cc:

Description (last modified by scribu)

prettyboymp in #10964:

For the most part, the found posts result is only needed for the main loop where paging is involved, yet, most developers don't know to add the 'no_found_rows' parameter to every single WP_Query request where they don't need paging. It would require creating a magic get() method for backwards compatibility, but it can throw a deprecated warning and switch to a real getter implementation.

Change History (7)

comment:1 scribu3 years ago

  • Description modified (diff)

comment:2 scribu3 years ago

Similar: #15773

comment:3 scribu3 years ago

Related: #17066

comment:4 pavelevap3 years ago

  • Cc pavelevap@… added

So, this problem is also related to default Recent Posts widget? I did not find parameter no_found_rows there and pagination is not required. I had some problems with slow queries which disappeared after removing this widget in the past...

comment:5 scribu3 years ago

Indeed. It sets 'nopaging' => 0 for some reason, although it also sets 'posts_per_page'.

Version 0, edited 3 years ago by scribu (next)

comment:6 ryan3 years ago

  • Milestone changed from 3.2 to Future Release

comment:7 scribu21 months ago

  • Milestone Future Release deleted
  • Resolution set to invalid
  • Status changed from new to closed

Actually, lazy loading found_posts isn't really possible since the query is dependent on the previously executed query, the one that contains SQL_CALC_FOUND_ROWS.

Would have been nice, though.

Note: See TracTickets for help on using tickets.