def calculate_with_static_record(operation, column_name, options={})#:nodoc:
      if scope(:find).nil? && !options.any?{ |k,v| k.to_s.downcase != 'distinct' }
        key = "#{operation}_#{column_name}_#{options.none?{|k,v| v.blank? }}"
        static_record_cache[:calc][key]||=
          case operation.to_s
          when 'count' then
              #count the cache if we want all or the unique primary key
              if ['all', '', '*', primary_key].include?(column_name.to_s)
                static_record_cache[:primary_key].length

              #otherwise compute the length of the output
              else
                static_records_for_calculation(column_name, options) {|records| records.length }
              end
          #compute the method directly on the result array
          when 'sum', 'max', 'min' then

              if columns_hash[column_name.to_s].try(:type) == :integer
                static_records_for_calculation(column_name, options) {|records| records.send(operation).to_i }
              end

          end

        return static_record_cache[:calc][key] if static_record_cache[:calc][key]

      end
      calculate_without_static_record(operation, column_name, options)
    end
def calculate_with_static_record(operation, column_name, options={})#:nodoc:
      if scope(:find).nil? && !options.any?{ |k,v| k.to_s.downcase != 'distinct' }
        key = "#{operation}_#{column_name}_#{options.none?{|k,v| v.blank? }}"
        static_record_cache[:calc][key]||=
          case operation.to_s
          when 'count' then
              #count the cache if we want all or the unique primary key
              if ['all', '', '*', primary_key].include?(column_name.to_s)
                static_record_cache[:primary_key].length

              #otherwise compute the length of the output
              else
                static_records_for_calculation(column_name, options) {|records| records.length }
              end
          #compute the method directly on the result array
          when 'sum', 'max', 'min' then

              if columns_hash[column_name.to_s].try(:type) == :integer
                static_records_for_calculation(column_name, options) {|records| records.send(operation).to_i }
              end

          end

        return static_record_cache[:calc][key] if static_record_cache[:calc][key]

      end
      calculate_without_static_record(operation, column_name, options)
    end
Override calculate to compute data in memory if possible
 Only processes results if there is no scope and the no keys other than distinct