Best way to get many metadatas of an entity or many entities

I don't understand how metadata and cache work together.

If I query many entities and get metadata of each like :

$entities = elgg_get_entities(...);
foreach($entities as $entity) {
    $md1 = $entity->md1;
    $md2 = $entity->md2;
    $md3 = $entity->md3;
}

There is the same count of queries in global $dbcalls if I remove this foreach loop or not !?

Could I reduce the number of queries like that ?

$entities = elgg_get_entities(...);
foreach($entities as $entity) {
    $mds = elgg_get_metadata(array(
        'guid' => $entity->getGUID(),
        'metadata_names' => array('md1', 'md2', 'md3')
    ));
}

There is a way to populate many entities with many metadata with the less queries possible ?

Performance and Scalability

Performance and Scalability

If you've got a need for speed, this group is for you.