altis-cms icon indicating copy to clipboard operation
altis-cms copied to clipboard

Viewing post list table with large number of hierarchical posts has unbounded query

Open rmccue opened this issue 1 year ago • 1 comments

wp_edit_posts_query() has an unbounded query that triggers when viewing a hierarchical post type; specifically, this code sets posts_per_page to be unlimited and overrides the order, but only when no orderby is set.

This means page loads can take vast amounts of time, but if you click on the Date column to "reorder" the page, it's suddenly fast, even though it renders the same page.

I've checked and VIP is overriding this when the page is loaded so clearly they've hit this issue previously too - we should apply a similar workaround to ensure the query is not unbounded.

Steps to reproduce:

  1. Create 100k+ pages or other hierarchical post type
  2. Load the list table for the post type
  3. Observe unbounded query in Query Monitor for the post

Acceptance criteria:

  • [ ] ...

rmccue avatar Dec 08 '23 13:12 rmccue

As an aside, Extended CPTs also does an unbounded, uncached SELECT DISTINCT post_author, presumably for the dropdown list?

rmccue avatar Dec 08 '23 13:12 rmccue