[wp-hackers] wp_options updates taking too long for page_uris and rewrite_rules

Ryan Boren ryan at boren.nu
Wed Aug 23 23:36:15 GMT 2006


Paul Menard wrote:
> Since Sunday Anytime someone goes in to edit/add and Event the database 
> locks up. This is a private hosted server with no other traffic. The 
> solution I've found that brings the site back is to remove the 
> 'page_uris' and rewrite_rules' records from the wp_options table. Then 
> let WP rebuild these. I've had to finally keep people off the system 
> otherwise it crashes hourly.

If it runs faster if those options are deleted first, then the culprit 
is likely the comparison check to see if the old value of page_uris is 
equal to the new value.  This is done to avoid an unnecessary DB update. 
  In this case, however, comparing two huge arrays for equality is much 
more expensive than just sending the update.  Try fixing it like this:

Look for the function named generate_page_rewrite_rules() in the 
wp-includes/functions-post.php file.

Within that function, look for this line:

update_option('page_uris', $page_rewrite_rules);

Right before that line, add this line:

delete_option('page_uris');

It should then look like this:

delete_option('page_uris');
update_option('page_uris', $page_rewrite_rules);

Try that out and let us know how it goes.

Ryan


More information about the wp-hackers mailing list