use query to count textflow to avoid lazy loading exception