Skip to content

Instantly share code, notes, and snippets.

@mallyvai
Created August 16, 2018 23:42
Show Gist options
  • Save mallyvai/7516fd0db5b5ebb7245cbade71029289 to your computer and use it in GitHub Desktop.
Save mallyvai/7516fd0db5b5ebb7245cbade71029289 to your computer and use it in GitHub Desktop.
require 'parallel'
Benchmark.measure do
query = ->(table) do
result = ActiveRecord::Base.connection.execute("CHECK TABLE #{table} EXTENDED;").to_a
puts result
result
end
result = Parallel.map(ActiveRecord::Base.connection.tables, in_processes: 10) { |table| query.call(table)}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment