﻿id,summary,reporter,owner,description,type,status,priority,milestone,component,version,severity,resolution,keywords,cc,difficulty
4543,More aggressive entity caching,ewinslow,ewinslow,"{{{
$entities = elgg_get_entities(array(...)); // complicated db call

get_entity($entities[0]->guid); //hits db again!

get_entity($entities[0]->guid); //hits db again!
}}}

The above situation is common and pointless. We already loaded the entity, we should just be able to hit a local cache (i.e. it should not require a shared memory cache like memcache).

Once we have this optimization in place for `elgg_get_entities`, we can (ab)use it as the basis for other optimizations. E.g. currently when you are displaying the river, it's 1 query to get all the relevant river entries, and then 1 more query per owner, and object, plus another for each set of comments, plus another for each comment's owner, etc.

Instead, in `elgg_get_river`, we can preload all the entities referenced from the results by looping over them, pulling out `owner_guid` and `object_guid` into an array, and then doing `elgg_get_entities(array('guids' => $guids));` Now `$item->getOwnerEntity()` and `$item->getObjectEntity()` will just hit the cache.

Since this is invisible to the API, we can include it in a bugfix release, so I'm slating for 1.8.x.",Enhancement,closed,high,Elgg 1.8.9,Core,1.7,major,fixed,,brett@…,moderate
