lib/pghero/methods/maintenance.rb in pghero-1.6.5 vs lib/pghero/methods/maintenance.rb in pghero-1.7.0
- old
+ new
@@ -54,8 +54,25 @@
pg_stat_user_tables
ORDER BY
1, 2
SQL
end
+
+ def analyze(table)
+ execute "ANALYZE #{quote_table_name(table)}"
+ true
+ end
+
+ def analyze_tables
+ table_stats.reject { |s| %w(information_schema pg_catalog).include?(s["schema"]) }.map { |s| s.slice("schema", "table") }.each do |stats|
+ begin
+ with_lock_timeout(5000) do
+ analyze "#{stats["schema"]}.#{stats["table"]}"
+ end
+ rescue ActiveRecord::StatementInvalid => e
+ $stderr.puts e.message
+ end
+ end
+ end
end
end
end