Support » Fixing WordPress » 2MB(!!!) rewrite_rules in database. Slow saving pages

  • deviation



    having many pages (around 600) saving a page slows down extremely. I found out that the rewrite rule query generation consumes that much time.

    Is there a way to optimize this behaviour? I am wondering because saving a post does not slow down …

    thx, best

Viewing 3 replies - 1 through 3 (of 3 total)
  • WP-Cache does not help in the saving and editing of pages. Once a “page” is actually saved, it loads at the same speed as the rest of the “posts” on the site.

    I’ve experienced similar issues with rewrite_rules (WP 2.2) – more to do with the database ‘max_allowed_packet’ bytes error when saving the rules to the database, but I think it’s the same all round.

    On examining the actual rules, it appears that up to 6 rules are inserted for each static page attachment, which to me appeared excessive (for my needs).

    So, I looked at the code, and in particular the function page_rewrite_rules (c. wp-includes/rewrite.php, Ln 264), and I changed the call to generate-rewrite_rules() to set the $feed parameter to false:

    if( is_array( $attachment_uris ) ) {
          foreach ($attachment_uris as $uri => $pagename) {
            $this->add_rewrite_tag('%pagename%', "($uri)", 'attachment=');
            $rewrite_rules = array_merge($rewrite_rules, $this->generate_rewrite_rules($page_structure, EP_PAGES, true, false));

    This has helped significantly to keep the rewrite rules shorter.

    Hopefully this can help someone else too.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘2MB(!!!) rewrite_rules in database. Slow saving pages’ is closed to new replies.