Will using pathauto slow down my site node loads?

Comments

greggles’s picture

The answer is both yes and no.

Pathauto will slow down the creation and editing of most objects (users, nodes, taxonomy) on your site because it does it's work of creating aliases during the creation/editing of those objects. Most people don't edit objects very often compared to how often a page is viewed so this is not a problem. This problem can be amplified if you have a lot of modules that provide a very large number of tokens or tokens which are expensive to calculate (see this issue where calculating a single alias takes 2,167 queries!).

The other place where Pathauto will slow down a site is when admins have a large number of objects on their site and configure Pathauto create aliases for every single object on a site (this is made worse when they also create feed aliases for every object). The reason this slows down a site is that for every page load, all links that Drupal creates are checked against an alias table. For example, at the top of this page are the node tabs for view, edit, and outline (depending on your permissions). When they are displayed, all of those links are checked against the url_alias table to see if there is an alias for them. When your site gets more and more entries in the url_alias table this query will take longer and longer. While it may be fast on it's own (fractions of a second) if you have a page that shows lots of links that are passed through l/url functions then having hundreds of those queries will add up to serious time.

So, in general Pathauto on its own will not slow down a site. But it certainly can make a site slow under certain circumstances.

greggles’s picture

Title: Pathauto slow down site? » Document Pathauto configurations that will slow down a site
Component: Miscellaneous » Documentation
Category: support » task

Also, I've been meaning to do some benchmarking to determine best practices here, so I'm going to turn this into an issue for that.

If anyone else wants to do that, it would be awesome :)

Freso’s picture

Version: 5.x-1.1 » 6.x-1.1
Status: Active » Postponed (maintainer needs more info)

This should probably be for 6.x-1.1/5.x-2.3 by now. If it's something we still wants to have done? (Seeing as it's been open for over 6 months without any activity, perhaps we should simply "won't fix" it?)

greggles’s picture

Status: Postponed (maintainer needs more info) » Active

Yes, I'd still like to do this...

mikeytown2’s picture

Version: 6.x-1.1 » 7.x-1.x-dev
Priority: Normal » Critical

line 360 - pathauto_taxonomy()

          // For all children generate new alias (important if [catpath] used)
          foreach (taxonomy_get_tree($category->vid, $category->tid) as $subcategory) {
            $count = _taxonomy_pathauto_alias($subcategory, $op);
          }

This was taking 20 seconds for SQL and about the same in PHP time; for each term added... and I don't have any aliases for taxonomy defined. I recommend adding in some sanity checks before running taxonomy_get_tree(), because that can be very expensive on large databases.
#572046: Each node takes longer to do. SQL Issue. Recommend disabling pathauto.module

greggles’s picture

What kind of sanity check do you suggest?

mikeytown2’s picture

Check if "Taxonomy term path settings" is completely blank; if so don't run.

mikeytown2’s picture

So if the Default path pattern is blank and that vocab is blank, don't run.

greggles’s picture

Priority: Critical » Normal

Seems like a great idea: #572604: If there is no taxonomy pattern, don't do any work.

But it's unrelated to the purpose of this issue.

dave reid’s picture

Do we need this issue open? This could be documented at any time under http://drupal.org/handbook/modules/pathauto.

greggles’s picture

Title: Document Pathauto configurations that will slow down a site » Find and then document Pathauto configurations that will slow down a site

Well, it's a matter of finding them first and then documenting them. New title to reflect that.

dave reid’s picture

Status: Active » Fixed

Anyone can edit documentation at any time. There's no need to keep an issue 'open' for it.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.