title: Ruby on Rails - get MySql DB size
body: <p>I want to know the current size of my MySql DB, to get that data I use the following methods:</p>
  
  <pre><code>def self.calculate_total_db_size
      sql = "SELECT table_schema AS 'database',
                    sum( data_length + index_length ) / ( 1024 *1024 ) AS size
                    FROM information_schema.TABLES
                    WHERE ENGINE=('MyISAM' || 'InnoDB' )
                    AND table_schema = '#{get_current_db_name}'"
      return  perform_sql_query(sql)
    end
  
  
  
  def self.get_current_db_name    
      return Rails.configuration.database_configuration[Rails.env]["database"]
  end
  
  def self.perform_sql_query(query)
       result = []
       mysql_res = ActiveRecord::Base.connection.execute(query)
       mysql_res.each_hash{ |res| result &lt;&lt; res }
       return result
  end
  </code></pre>
  
  <p>this works great in my development and staging environment, but from some reason when i run it in production the query doesnt return any value, if i take the MySql query and run it manually on my production DB I get the correct values. why cant i do it through  the application in production?</p>
  
  <p>any thoughts?</p>