Optimize database access during tool rendering.

Prefetch all child, 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. 10x speed up on my laptop with ~400 history items - tool form update time drops from 5 seconds to half a second. That is with sqlite database on local SSD, I imagine with remote databases this speed could be even more significant.