Tag Archives: admin

Faster wordpress page admin

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.

After profiling the code with xdebug and Kcachegrind I found there were a few parts of the code that were taking the longest time to complete.

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  ).

The Solution

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 : Fast page_get_children-0.1 (1.05 KB)

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.

MacOSX for Unix admins

I'm going to write some posts about doing stuff on MacOSX.

I'm a beginner mac user and I come from a Unix background. I use/administrate/patch/develop on Unix like machines ( mostly just Linux and FreeBSD ) on a daily basis.

Since MacOSX has Unix at it's roots using it shouldn't be hard for me to work with it...right...well I'll see how much it has changed.

Sometimes I find it difficult to do something on MacOSX mostly because I am used to how it is done in Unix and because I don't want or can't use the GUI tools.

The fact that most of the tutorials I find are also  explaining how to do stuff in the GUI makes this an even bigger problem.

So I decided that when I actually find out how to do what I want to do I will write a post  about it so I will not have to look for it again.