Support » Fixing WordPress » Custom Permalink DRAMATICALLY slows website

  • Michael86


    As the title says. Using a custom permalink structure will dramatically slow down the website. Its nice having relevant permalinks that give structure, but is it worth it? I’m trying to find a way to have both a custom permalink and optimal performance on my website.

    Using “/%category%/%postname%/” as my custom permalink structure, loading my homepage takes ~3,000 queries taking ~5.0 seconds.

    Using the default permalink structure (‘’), loading my homepage takes ~20 queries loading in ~0.5 seconds.

    To get this information and figure out which queries i am making, i added the following line to my footer to find out the #of queries and time taken to perform those:

    <?php echo get_num_queries(); ?> queries. <?php timer_stop(1); ?> seconds.

    And the plugin ‘Debug Queries’ to print out which queries are being ran on what page (adds info to the bottom of footer). Most of the queries look like this:

    Time: 0.0001060962677002
    Query: SELECT * FROM wp_posts WHERE ID = 3121 LIMIT 1
    Call from: require, wp, WP->main, WP->parse_request, WP_Rewrite->wp_rewrite_rules, WP_Rewrite->rewrite_rules, WP_Rewrite->page_rewrite_rules, WP_Rewrite->page_uri_index, get_page_uri, get_page, get_post

    Anyone have any ideas of how to keep the “fancy” permalink structure while maintain the performance of the default and cut down on all of those DB-Queries?

Viewing 2 replies - 1 through 2 (of 2 total)
  • MichaelH


    From Using Permalinks

    For performance reasons, it is not a good idea to start your permalink structure with the category, tag, author, or postname fields. The reason is that these are text fields, and using them at the beginning of your permalink structure it takes more time for WordPress to distinguish your Post URLs from Page URLs (which always use the text “page slug” as the URL), and to compensate, WordPress stores a lot of extra information in its database (so much that sites with lots of Pages have experienced difficulties). So, it is best to have at least two path segments in your post’s permalink structure such as /%year%/%post_name%/ or even /posts/%post_name/. (Some people recommend /%post_id%/%post_name%/ which works for performance reasons but others recommend against it because it is unfriendly to users in the many contexts in which users interact with URLs.) See Otto’s technical writeup on the topic as well as this wp-testers discussion.



    it is not a good idea to start your permalink structure with the category, tag, author, or postname fields

    Even when i use “/web/%category%/%postname%/” or “/posts/%postname%/” its still ~3,000.

    However “/%post_id%/%postname%/” Seems to work. But still isn’t really what i wanted.

    That’s going to require me to manually change every link on my site (NOT FUN!)

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom Permalink DRAMATICALLY slows website’ is closed to new replies.