Access pages data with fewer queries by creating an object in Twig
So the only database queries in your example will be generated by:

{% set navigation = craft.entries.section('pages').all() %}


So creating an additional object doesn't serve the stated purpose of saving db queries. You can just access the navigation array directly.