I created for you a simple class which should do exactly what i said.
In fact, with 1 query per page now i have all my data ready for a better frontend performance.
You can find the Gist here: https://gist.github.com/teolaz/dc595d5beed29ddad18066d01c237464