Solved

Wordpress - Extremely Slow on Large Site - get_page_children Function Responsible

Posted on 2012-12-28
1
821 Views
Last Modified: 2013-05-13
I'm converting a large information site from HTML to Wordpress.  There are over 10,000 pages of content.  On some themes the site crawls, on basic themes like TWENTY TWELVE it flies.

What I have isolated is a function function in post.php that is causing the slow down.  

/**

COMMENTED OUT BY ME

function get_page_children($page_id, $pages) {
     $page_list = array();
     foreach ( (array) $pages as $page ) {
          if ( $page->post_parent == $page_id ) {
               $page_list[] = $page;
               if ( $children = get_page_children($page->ID, $pages) )
                    $page_list = array_merge($page_list, $children);
          }
     }
     return $page_list;
}
*/

/**
Added by ME
*/

function get_page_children($page_id, $pages) {
     $page_list = array();
     return $page_list;
}

Open in new window


Basically, it seemed to be doing a tremendous number of recursive searches over 10,000+ pages looking for matches.

Is there a more efficient way to do this with a SQL query and, if yes, what would you do?

This has been a temporary fix.... the site is now flying.  The Parent / Child plugins we use do not make use of this function.

The only thing I've seen it break is:

http://www.XXXXXXXXXXXXXXX.com/wp-admin/edit.php?post_type=page

This would list all pages on the site that we could edit, albeit at 20 pages per screen.

Other than that, is this a problem?  Is there a better way to do it?  I know sites this size are unusual but should not be impossible.  

I know this is well established code in WP, but it cannot be the most efficient way of handling things when dealing with a large site.

Finally, is there any way for me to take whatever function is recommended and make it a child theme / function / something that "takes priority" over the one built into post.php?

I can edit post.php but if we do a WP update, it will wipe the change.  I'm wondering if you can have priority functions, the way you would take precedence in CSS.

Thanks!
0
Comment
Question by:drgdrg
1 Comment
 
LVL 70

Accepted Solution

by:
Jason C. Levine earned 500 total points
ID: 38728735
On some themes the site crawls, on basic themes like TWENTY TWELVE it flies.

I don't doubt this but the code you commented out is in the core.  If you see a difference between themes, it means that there is something in the loop call that is different between the two themes that is causing the site to slow down.

Is there a more efficient way to do this with a SQL query and, if yes, what would you do?

Potentially.  Is this problem on the backend or the front end?

 I know sites this size are unusual but should not be impossible.  

Are you sure the database server is robust enough to handle a table of this size?

whatever function is recommended and make it a child theme / function / something that "takes priority" over the one built into post.php

Depending on exactly how we solve this, it could be done with a hook.  Not sure which one at this time though.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part I (http://www.experts-exchange.com/Web_Development/Blogs/WordPress/A_8410-Getting-Started-In-WordPress-Part-I.html), I introduced you to the powerful WordPress backend, the WordPress administrative Dashboard.  In Part II, I will introduce yo…
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
This video teaches users how to migrate an existing Wordpress website to a new domain.
The purpose of this video is to demonstrate how to set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question