WordPress.org

Ready to get started?Download WordPress

Forums

2MB(!!!) rewrite_rules in database. Slow saving pages (4 posts)

  1. deviation
    Member
    Posted 7 years ago #

    Hi,

    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

  2. Samuel B
    moderator
    Posted 7 years ago #

  3. kineda
    Member
    Posted 7 years ago #

    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.

  4. agei
    Member
    Posted 6 years ago #

    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.
    /A

Topic Closed

This topic has been closed to new replies.

About this Topic