def query_count (&block)

      q = prepare_query { |q|
        q.pk_only  # improve efficiency, since we have to do the query
      }
      q.count
    ensure
      q.free if q
    end
def query_count (&block)

      q = prepare_query { |q|
        q.pk_only  # improve efficiency, since we have to do the query
      }
      q.count
    ensure
      q.free if q
    end
Prepares a query and then runs it and deletes all the results.