Index: includes/entity.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/entity.inc,v
retrieving revision 1.13
diff -u -p -r1.13 entity.inc
--- includes/entity.inc	22 Aug 2010 16:11:12 -0000	1.13
+++ includes/entity.inc	13 Sep 2010 16:39:37 -0000
@@ -239,6 +239,10 @@ class DrupalDefaultEntityController impl
    *   A SelectQuery object for loading the entity.
    */
   protected function buildQuery($ids, $conditions = array(), $revision_id = FALSE) {
+    $cid = 'schema:' . get_class($this) . ':' . __FUNCTION__;
+    // @todo Fast?
+    $schema_cache = &drupal_static($cid);
+
     $query = db_select($this->entityInfo['base table'], 'base');
 
     $query->addTag($this->entityType . '_load_multiple');
@@ -251,11 +255,24 @@ class DrupalDefaultEntityController impl
     }
 
     // Add fields from the {entity} table.
-    $entity_fields = drupal_schema_fields_sql($this->entityInfo['base table']);
+    if (!isset($schema_cache)) {
+      if ($cache = cache_get($cid)) {
+        $schema_cache = $cache->data;
+      }
+      else {
+        $schema_cache = array();
+        $schema_cache['base table'] = drupal_schema_fields_sql($this->entityInfo['base table']);
+        if ($this->revisionKey) {
+          $schema_cache['revision table'] = drupal_schema_fields_sql($this->revisionTable);
+        }
+        cache_set($cid, $schema_cache);
+      }
+    }
+    $entity_fields = $schema_cache['base table'];
 
     if ($this->revisionKey) {
       // Add all fields from the {entity_revision} table.
-      $entity_revision_fields = drupal_map_assoc(drupal_schema_fields_sql($this->revisionTable));
+      $entity_revision_fields = drupal_map_assoc($schema_cache['revision table']);
       // The id field is provided by entity, so remove it.
       unset($entity_revision_fields[$this->idKey]);
 
