In a recent post about wordpress I explained how you can create a lot of pages really fast. If that went well and you inserted a few thousand pages in your wordpress blog the page admin became useless. Displaying the list of pages would take 3 minutes for 7000 pages on my test server.
It seems this is not a new problem and there is a bug created in 2007 about it. Although it seems like there was a patch to fix this, the problem still exists in the 2.8.4 version.
Why is this so slow ?
Short story: because wordpress is trying to display and sort pages hierarchically .
At first I thought the problem was caused by the sql queries that fetched all the pages ( even though it doesn't display all of them on a page ) but that was not the case.
The main problem is that wordpress is trying to find the children for all the pages in an inefficient way. There is this function get_page_children in wp-includes/post.php which was taking about 2 thirds of the total time to complete ( ~ 2 minutes on my example ).
I rewrote that function to make it a lot more efficient. In my case it reduced the time from 2 minute to 1-2 seconds but on other page hierarchy it might take more, the worst case being when every page is the parent of another page. The diff is here : [download id="15"]
The second problem is that wordpress updates the page cache every time you list pages. This was taking almost 1 minute to complete. I'm not sure if it's the right thing to just remove that call to update_page_cache in wp-includes/post.php get_pages , but doing that made the page admin load in about 15 seconds.
Now this might still be annoying but it's way better then 3 minutes. Hopefully at least the new get_page_children function will b included in the next wordpress release... maybe you can help promote this ticket by giving it a positive vote although I'm not sure if those votes actually have any influence.