Only perform queries if requested. #1177