Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#5458 closed defect (bug) (fixed)

making get_pages and wp_list_pages faster

Reported by: hailin Owned by: ryan
Milestone: 2.5 Priority: normal
Severity: normal Version:
Component: Optimization Keywords: has-patch needs-testing
Focuses: Cc:


When there are a lot of pages, these functions slow down quite a bit.
Should improve on the algorithm so that they speed up. (using logic similar to 5303).

Attachments (2)

5458_walk_core.diff (7.3 KB) - added by hailin 9 years ago.
no_hier_pages.diff (426 bytes) - added by ryan 9 years ago.

Download all attachments as: .zip

Change History (13)

#1 @hailin
9 years ago

  • Owner changed from anonymous to hailin
  • Status changed from new to assigned

#2 @hailin
9 years ago

Per Ryan's request, I've rewrote the Walk class which is a core class used in wp_list_pages, etc to generate nested pages.

The resulting implemenation is much faster, with O(N) time complexity.
and the code is more simple, thus easier to understand and maintain.

Tested on my local wporg and wpcom sandbox.

9 years ago


#3 @ryan
9 years ago

Working well in my tests. Now we can set hierarchical to false when calling get_pages() and get_terms() to avoid the hierarchy sorting done in those functions. Actually, get_terms() will require some finesse because it does some things to counts for term hierarchies.

#4 @ryan
9 years ago

(In [6384]) Faster page and cat walker. Props hailin. see #5458

9 years ago

#5 @ryan
9 years ago

Small patch that calls get_pages() with heirarchical set to 0 since the new walker code doesn't need get_pages() to pre-sort the results. Need to profile this with lots of pages.

#6 @lloydbudd
9 years ago

  • Milestone changed from 2.5 to 2.4

#7 @ryan
9 years ago

(In [6399]) wp_list_pages() no longer requires get_pages() to do a hierarchical sort. Set hierarchical to false. see #5458

#8 @darkdragon
9 years ago

  • Component changed from General to Optimization

I think this should be moved to optimization, so I'm moving this to that category.

#9 @hansengel
9 years ago

  • Keywords has-patch needs-testing added

#10 @ryan
9 years ago

  • Owner changed from hailin to ryan
  • Status changed from assigned to new

#11 @ryan
9 years ago

  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.