How to speed up Drupal 5.2 lots
Sep. 14th, 2007 12:24 amEarlier tonight, I was trying to figure out why a Drupal installation of mine was running kinda slow. So, I installed the awesome devel module and had it print out the list of database queries. What I found when going through the forums was on each post there were dozens and dozens of calls to drupal_lookup_path() for URLs which I never had (or will) make aliases of. Namely URLs that start with "comment/" or "user/".
So, I wrote a little patch for that function which will skip querying the database for URLs like that:
You will see the most gain with forum posts that have many comments, but even on regular pages you should see some benefit. Enjoy!
So, I wrote a little patch for that function which will skip querying the database for URLs like that:
--- includes/path.inc 2007/09/14 00:06:12 1.1 +++ includes/path.inc 2007/09/14 00:15:21 @@ -44,6 +44,21 @@ static $map = array(), $no_src = array(); static $count; + // + // Drupal does an INSANE number of these queries for comment lnks + // and such on long threads, and that's just unacceptable. Since + // I plan on like, never setting up a URL alias on a comment or + // a user, I'm just going to stop here... + // + if ( + stristr($path, "comment/") + || stristr($path, "user/") + ) { + return(false); + } + // Use $count to avoid looking up paths in subsequent calls if there simply are no aliases if (!isset($count)) { $count = db_result(db_query('SELECT COUNT(pid) FROM {url_alias}'));
You will see the most gain with forum posts that have many comments, but even on regular pages you should see some benefit. Enjoy!