optimizing db hierarchy load