This Advice May Help You If Your Drupal 7 Has Started To Run Slowly

28 May · by Tim Kamanin · 2 min read

Just wanted to make a quick share on how to solve one weird Drupal 7 performance related problem. Picture this. Yesterday, your Drupal 7 site run pretty ok, but today it as slow as a snail and you don't remember yourself changing anything. I myself encountered this problem today and spend a good hour looking for a problem source. My problem was connected to a so-called "Avoid re-scanning module directory when multiple modules are missing" bug which is still not resolved. This problem happens if you have some missing modules in your Drupal installation. For example, you could delete or rename module while it's enabled (which happens often on a development machine).

The Solution

Go to your phpmyadmin and run this query:

SELECT name, filename FROM system WHERE type = 'module' AND status = 1 ORDER BY filename;

You will get a list of all enabled modules. Now verify if you don't have any missing modules in this list. If some modules are missing in your file system do either:

  1. bring the module back and then disable it in your modules list, uninstalling after this. ( The best and safe practice.)
  2. delete corresponding row in the 'system' table. ( Do this with caution and only when you can 't bring the module back, for example, when you develop a module and just renamed it, but forgot to disable it.)
  3. and the most elegant way, but, unfortunatelly, it works if you're on Linux and have Drush installed, type this in your Drupal root folder:
for FN in `drush --extra=--skip-column-names sql-query "SELECT filename FROM system WHERE status = 1"`; do [ ! -f $FN ] && echo "Missing $FN"; done

Credits to a reader with a nickname _lyricnz_ for this tip.

NOTE: Always backup your db before doing any moves!. I hope this advice will help someone.

Comments

Required for comment verification



alexeinandrosdev

Brilliant!

Reply · 6 years, 6 months ago
anon

your copy past of lyricnz example is missing the for at the start. thanks for the tip!

Reply · 6 years, 6 months ago
Christopher Pelham

Would it be safer to just turn off the missing module in the system table?

Reply · 6 years, 6 months ago
lyricnz

One-liner, if you have bash+drush: for FN indrush --extra=--skip-column- names sql-query "SELECT filename FROM system WHERE status = 1"; do [ ! -f $FN ] && echo "Missing $FN"; done (Add prefix to "system" if you have one)

Reply · 6 years, 6 months ago
Fabianx

To make this more useful consider the following snippet (considering you have drush): $ echo "SELECT filepath FROM system WHERE status = 1" | drush sql-cli | while read i; do test -f "$i" || echo "$i is missing." That is a little quicker than checking manually ... Needs to be run from the root of your drupal installation (obviusly) I also use a variation of this to check the files table for missing files and possible 404s. Best Wishes, Fabian

Reply · 6 years, 6 months ago
Mike Keran

Thanks for the tip! Rather than deleting the row from the system table, it's a better practice to reload the module, disable it and then uninstall it so that it has a chance to delete and module-specific system variables or database tables. Then you can blow away the module code without it leaving any remnants behind.

Reply · 6 years, 6 months ago