Prevent sql query on subsequent calls to the count method