我尝试从子域的名称中获取架构的大小。公共架构中的子域名称,
在控制器.rb
@account = Account.find_by_subdomain(params[:subdomain])
@itemlist = Account.find(:all,:select => 'subdomain')
@schemasize = ActiveRecord::Base.connection.select_rows(%q{select pg_size_pretty(CAST((SELECT SUM(pg_total_relation_size(table_schema || '.' || table_name) ) FROM information_schema.tables WHERE table_schema = '}+@itemlist.to_s+%q{') As bigint) ) As schema_size}).to_s.gsub(/\D/, '').to_i
获取 localhost:3000/namesubdomain
命令提示符下的输出
(21.0ms) select pg_size_pretty(CAST((SELECT SUM(pg_total_relation_size(table
_schema || '.' || table_name) ) FROM information_schema.tables WHERE table_schem
a = '[#<Account subdomain: "namesubdomain">]') As bigint) ) As schema_size
我想在命令提示符下输出,例如
(151.0ms) select pg_size_pretty(CAST((SELECT SUM(pg_total_relation_size(tabl
e_schema || '.' || table_name) ) FROM information_schema.tables WHERE table_sche
ma = 'namesubdomain') As bigint) ) As schema_size
任何的想法?