add utility function getQueryCount to count query with functions