Simple Drupal page loads very slowly; slow 'DrupalDatabaseCache::getMultiple' query I've installed Drupal (and CiviCRM within Drupal) on shared hosting my group's host assures me is adequate (though they refuse to enable PHP caching like APC on it). It's generally far slower than my installs on other servers or my home Mac. Even the simple, completely default Drupal front page (which just shows one promoted story, the only extra blocks being from the Devel module) loads slowly. Just now it took a minute, and the Devel block reported the following slow queries. Any help solving or at least diagnosing the problem very welcome!


  ms | # | where | ops | query | target
  
  41.05 | 21 | DrupalDatabaseCache::getMultiple | P A E | 
  SELECT cid, data, created, expire, serialized FROM drupal_cache_menu WHERE cid IN (:cids_0)
  default
  
  32.97 | 21 | DrupalDatabaseCache::getMultiple | P A E | 
  SELECT cid, data, created, expire, serialized FROM drupal_cache_menu WHERE cid IN (:cids_0)
  default
  
  28.13 | 21 | DrupalDatabaseCache::getMultiple | P A E | 
  SELECT cid, data, created, expire, serialized FROM drupal_cache_menu WHERE cid IN (:cids_0)
  default
Devel is telling you how slow the query is. From what you wrote on your question it does not appear however to be telling you what is executing that query. I would attempt to locate the source of that query first, since your doctor can't issue you a prescription, if he does not know your ailment first.

I tried searching my D7 codebase for the string "drupal_cache_menu" and did not find anything. So perhaps that is coming from a contrib module? Otherwise it would have shown up in my search. Regardless, you can see the pattern I used to locate the code responsible for that query:


Select a unique string from the query (I tried using an individual word).
Search your whole codebase for that string.
See if the matches returned from your search could possibly relate to the slow query.


Once you locate the source of the query then you will (most likely) be able to determine if the slow query was caused by:


An error.
A view (in which case all you have to do to solve the problem is set the caching for that View).
Legit custom code (without errors) that just needs optimization, in this case you could implement Drupal's Cache API (the cache_get() and cache_set() functions) and maybe static caching as well. The nice thing about the Cache API is that you can benefit from implementing it even when you don't have external persistent cache stores such as Memcached and APC installed. Lullabot's now classic Caching guide for beginners might well help you out as well.
Legit contrib code (without errors) that just needs optimization. In this case you would probably be better off consulting the module mantainer.


As you see, the corrective actions are too many to list, and which one you will take will depend on the source of the query.