Query for cached graphs improved