Class: Webhookdb::Postgres::Maintenance::Tables
- Inherits:
-
Query
- Object
- Base
- Query
- Webhookdb::Postgres::Maintenance::Tables
show all
- Defined in:
- lib/webhookdb/postgres/maintenance.rb
Instance Attribute Summary
Attributes inherited from Base
#service_integration
Instance Method Summary
collapse
Methods inherited from Query
#connstr, #fetch
Methods inherited from Base
#conn_params, #debug?, #initialize
Instance Method Details
#query ⇒ Object
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
# File 'lib/webhookdb/postgres/maintenance.rb', line 138
def query
return " SELECT\n relname AS \"relation\",\n reltuples as \"tuples\",\n pg_size_pretty(pg_total_relation_size(C .oid)) as \"size\"\n FROM pg_class C\n LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)\n WHERE nspname NOT IN ('pg_catalog', 'information_schema')\n AND C.relkind = 'r'\n AND nspname !~ '^pg_toast'\n ORDER BY C.relname\n SQL\nend\n"
|
#run ⇒ Object
153
154
155
|
# File 'lib/webhookdb/postgres/maintenance.rb', line 153
def run
return self.fetch
end
|
#run_fmt ⇒ Object
157
158
159
160
161
162
163
164
|
# File 'lib/webhookdb/postgres/maintenance.rb', line 157
def run_fmt
rows = self.run
namejust = rows.map { |r| r[:relation].size }.max
return rows.map do |r|
tuples = ActiveSupport::NumberHelper.number_to_delimited(r[:tuples].to_i).rjust(12, " ")
"#{r[:relation].ljust(namejust + 1, ' ')} #{r[:size].ljust(7, ' ')} #{tuples}"
end.join("\n")
end
|