Optimize database access during tool rendering.

Prefetch all children, permission, and role data that will be needed for calculation in first database call. Number of database calls no longer proporational to size of history. 17x speed up on my laptop with ~400 history items - typical tool form update times drop from over 5 seconds to under a third of a second. That is with sqlite database on local SSD, I imagine with remote databases and/or larger histories this speed improvement could be even more significant.